Builder/Window.js
[app.Builder.js] / Builder / Window.js
1 Gtk = imports.gi.Gtk;
2 Gdk = imports.gi.Gdk;
3 Pango = imports.gi.Pango;
4 GLib = imports.gi.GLib;
5 Gio = imports.gi.Gio;
6 GObject = imports.gi.GObject;
7 GtkSource = imports.gi.GtkSource;
8 WebKit = imports.gi.WebKit;
9 Vte = imports.gi.Vte;
10 console = imports.console;
11 XObject = imports.XObject.XObject;
12 Window=new XObject({
13     xtype: Gtk.Window,
14     type : Gtk.WindowType.TOPLEVEL,
15     title : "Application Builder",
16     border_width : 0,
17     init : function() {
18          this.atoms = {
19                "STRING" : Gdk.atom_intern("STRING")
20         };
21         this.targetList = new Gtk.TargetList();
22         this.targetList.add( this.atoms["STRING"], 0, 0);
23         //imports.Builder.Provider.ProjectManager.ProjectManager.loadConfig();
24     Gtk.rc_parse_string(
25                 "style \"gtkcombobox-style\" {\n" + 
26                 "    GtkComboBox::appears-as-list = 1\n" +
27                 "}\n"+
28                 "class \"GtkComboBox\" style \"gtkcombobox-style\"\n");
29         XObject.prototype.init.call(this);
30         this.el.show_all();
31         
32        
33                   
34     },
35     default_width : 800,
36     default_height : 500,
37     id : "Window",
38     listeners : {
39         "delete_event":function (self, event) {
40             return false;
41         },
42         "destroy":function (self) {
43            Gtk.main_quit();
44         },
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();
51         
52         }
53     },
54     items : [
55         {
56             xtype: Gtk.VBox,
57             id : "w-vbox",
58             items : [
59                 {
60                     xtype: Gtk.MenuBar,
61                     pack : "pack_start,false,false",
62                     items : [
63                         {
64                             xtype: Gtk.MenuItem,
65                             use_underline : true,
66                             label : "_File",
67                             items : [
68                                 {
69                                     xtype: Gtk.Menu,
70                                     pack : "set_submenu",
71                                     items : [
72                                         {
73                                             xtype: Gtk.MenuItem,
74                                             use_underline : true,
75                                             label : "New _Project",
76                                             listeners : {
77                                                 "activate":function (self) {
78                                                          var _this = this;
79                                                         this.get('/EditProject').show({
80                                                             success : function(pr) {
81                                                                      _this.get('/LeftProjectTree').get('combo').setValue(pr.fn);
82                                                             }
83                                                         });
84                                                 }
85                                             }
86                                         },
87                                         {
88                                             xtype: Gtk.MenuItem,
89                                             label : "_New File",
90                                             use_underline : true,
91                                             listeners : {
92                                                 "activate":function (self) {
93                                                         var fn = this.get('/LeftProjectTree.combo').getValue();
94                                                         if (!fn) {
95                                                             this.get('/LeftProjectTree').showNoProjectSelected();
96                                                             return true;
97                                                         }
98                                                         var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
99                                                         this.get('/DialogNewComponent').show({
100                                                             project : pm.getByFn(fn)
101                                                         });
102                                                 }
103                                             }
104                                         },
105                                         {
106                                             xtype: Gtk.SeparatorMenuItem,
107                                             pack : "add"
108                                         },
109                                         {
110                                             xtype: Gtk.MenuItem,
111                                             use_underline : true,
112                                             pack : "add",
113                                             label : "D_elete Project",
114                                             listeners : {
115                                                 "activate":function (self) {
116                                                 
117                                                         var fn =  this.get('/LeftProjectTree').get('combo').getValue();
118                                                         if (!fn.length) {
119                                                                 this.get('/StandardErrorDialog').show("Select a project")
120                                                                 return;
121                                                         }
122                                                         var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
123                                                         var pr  = pm.getByFn(fn);
124                                                 
125                                                         // confirm..
126                                                         this.get('/DialogConfirm').show("Are you sure you want to delete project '" + pr.name + "'", function() {
127                                                                 pm.deleteProject(fn);
128                                                                 print("DELETE?");
129                                                         });
130                                                 
131                                                 }
132                                             }
133                                         },
134                                         {
135                                             xtype: Gtk.SeparatorMenuItem,
136                                             pack : "add"
137                                         },
138                                         {
139                                             xtype: Gtk.MenuItem,
140                                             pack : "add",
141                                             label : "_Quit",
142                                             use_underline : true,
143                                             listeners : {
144                                                 "activate":function (self) {
145                                                    Gtk.main_quit();
146                                                 }
147                                             }
148                                         }
149                                     ]
150                                 }
151                             ]
152                         },
153                         {
154                             xtype: Gtk.MenuItem,
155                             label : "Help"
156                         }
157                     ]
158                 },
159                 {
160                     xtype: Gtk.HPaned,
161                     id : "left",
162                     position : 400,
163                     items : [
164                         {
165                             xtype: Gtk.HBox,
166                             items : [
167                                 {
168                                     xtype: Gtk.VPaned,
169                                     position : 300,
170                                     id : "leftvpaned",
171                                     items : [
172                                         {
173                                             xtype: Gtk.VBox,
174                                             id : "LeftTopPanel",
175                                             items : [
176                                                 {
177                                                     xtype: Gtk.Expander,
178                                                     label : "Select Project",
179                                                     id : "expander",
180                                                     pack : "pack_start,false,true",
181                                                     init : function() {
182                                                         XObject.prototype.init.call(this);
183                                                        this.el.add_events (Gdk.EventMask.BUTTON_MOTION_MASK );
184                                                     },
185                                                     listeners : {
186                                                         "activate":function (self) {
187                                                                 var nb = this.get('/LeftTopPanel.notebook');
188                                                                 if (this.el.expanded) {
189                                                                     // now expanded..
190                                                                     
191                                                                     var pm  = imports.Builder.Provider.ProjectManager.ProjectManager;
192                                                                     
193                                                                    
194                                                                     var model = this.get('/LeftProjectTree.combomodel');
195                                                                   //  print ("loading Projects?")
196                                                                 //console.dump(pm.projects);
197                                                                     model.loadData(pm.projects);
198                                                                      
199                                                                     
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);
204                                                                     //}
205                                                                     return;
206                                                                 }
207                                                                 nb.el.set_current_page(0);
208                                                         },
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);
213                                                         //   }
214                                                         
215                                                         return true;
216                                                         }
217                                                     }
218                                                 },
219                                                 {
220                                                     xtype: Gtk.Notebook,
221                                                     id : "notebook",
222                                                     show_border : false,
223                                                     show_tabs : false,
224                                                     pack : "pack_start,true,true",
225                                                     init : function() {
226                                                         XObject.prototype.init.call(this);
227                                                         this.el.set_current_page(0);
228                                                     
229                                                     },
230                                                     items : [
231                                                         {
232                                                             xtype: Gtk.ScrolledWindow,
233                                                             pack : "add",
234                                                             shadow_type : Gtk.ShadowType.IN,
235                                                             init : function() {
236                                                                 XObject.prototype.init.call(this);
237                                                                 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
238                                                             },
239                                                             id : "LeftTree",
240                                                             getPaleteProvider : function() {
241                                                                 var model = this.get('model');
242                                                                 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
243                                                                 return pm.getPalete(model.file.getType());
244                                                             },
245                                                             renderView : function() {
246                                                                 var render = this.getRenderer();
247                                                                 var model = this.get('model');
248                                                                 if (render) {
249                                                                     render.renderJS(model.toJS(false,true)[0]);
250                                                                 }
251                                                             },
252                                                             getRenderer : function() {
253                                                                    var model = this.get('model');
254                                                             //  print("RENDER VIEW?" + model.file.getType());
255                                                                 switch( model.file.getType()) {
256                                                                         case 'Roo':
257                                                                             this.get('/RightBrowser.view');
258                                                                         case 'Gtk':
259                                                                             return this.get('/RightGtkView');
260                                                                 }
261                                                             
262                                                             },
263                                                             getActivePath : function() {
264                                                                 var model = this.get('model');
265                                                                 var view = this.get('view');
266                                                                 if (view.selection.count_selected_rows() < 1) {
267                                                                     return false;
268                                                                 }
269                                                                 var iter = new Gtk.TreeIter();
270                                                             
271                                                                 view.selection.get_selected(model.el, iter);
272                                                                 return model.el.get_path(iter).to_string();
273                                                             },
274                                                             items : [
275                                                                 {
276                                                                     xtype: Gtk.TreeView,
277                                                                     pack : "add",
278                                                                     id : "view",
279                                                                     headers_visible : false,
280                                                                     enable_tree_lines : true,
281                                                                     tooltip_column : 1,
282                                                                     init : function() {
283                                                                                 XObject.prototype.init.call(this);
284                                                                         var description = new Pango.FontDescription.c_new();
285                                                                         description.set_size(8000);
286                                                                         this.el.modify_font(description);
287                                                                     
288                                                                         this.selection = this.el.get_selection();
289                                                                         this.selection.set_mode( Gtk.SelectionMode.SINGLE);
290                                                                         var _this = this;
291                                                                     
292                                                                         // is this really needed??
293                                                                         this.selection.signal['changed'].connect(function() {
294                                                                                 _this.get('/LeftTree.view').listeners.cursor_changed.apply(
295                                                                                     _this.get('/LeftTree.view'), [ _this.get('/LeftTree.view'), '']
296                                                                                 );
297                                                                         });
298                                                                     
299                                                                         Gtk.drag_source_set (
300                                                                                 this.el,            /* widget will be drag-able */
301                                                                                 Gdk.ModifierType.BUTTON1_MASK,       /* modifier that will start a drag */
302                                                                                 null,            /* lists of target to support */
303                                                                                 0,              /* size of list */
304                                                                                 Gdk.DragAction.COPY   | Gdk.DragAction.MOVE           /* what to do with data after dropped */
305                                                                         );
306                                                                     
307                                                                         Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
308                                                                     
309                                                                         Gtk.drag_source_add_text_targets(this.el); 
310                                                                         Gtk.drag_dest_set
311                                                                         (
312                                                                             this.el,              /* widget that will accept a drop */
313                                                                             Gtk.DestDefaults.MOTION  | Gtk.DestDefaults.HIGHLIGHT,
314                                                                             null,            /* lists of target to support */
315                                                                             0,              /* size of list */
316                                                                             Gdk.DragAction.COPY   | Gdk.DragAction.MOVE       /* what to do with data after dropped */
317                                                                         );
318                                                                     
319                                                                         Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
320                                                                         Gtk.drag_dest_add_text_targets(this.el);
321                                                                     },
322                                                                     highlight : function(treepath_ar) {
323                                                                     
324                                                                             // highlighting for drag/drop
325                                                                             if (treepath_ar.length && treepath_ar[0].length ) {
326                                                                                 this.el.set_drag_dest_row( 
327                                                                                         new  Gtk.TreePath.from_string( treepath_ar[0] ),  treepath_ar[1]);
328                                                                                 } else {
329                                                                                     this.el.set_drag_dest_row(null, Gtk.TreeViewDropPosition.INTO_OR_AFTER);
330                                                                                 }
331                                                                                  
332                                                                             },
333                                                                     selectNode : function(treepath_str) {
334                                                                         //this.selection.select_path(new  Gtk.TreePath.from_string( treepath_str));
335                                                                      var tp = new Gtk.TreePath.from_string(treepath_str);
336                                                                               this.el.set_cursor(tp, null, false);  
337                                                                           this.el.scroll_to_cell(tp, null, false, 0,0);
338                                                                     },
339                                                                     listeners : {
340                                                                         "button_press_event":function (self, ev) {
341                                                                                 console.log("button press?");
342                                                                                 if (ev.type != Gdk.EventType.BUTTON_PRESS  || ev.button.button != 3) {
343                                                                                     print("click" + ev.type);
344                                                                                     return false;
345                                                                                 }
346                                                                               
347                                                                             
348                                                                                 var res = {}; 
349                                                                                 this.get('/LeftTree.view').el.get_path_at_pos(ev.button.x,ev.button.y, res);
350                                                                                 
351                                                                                 if (!this.get('/LeftTreeMenu').el)  this.get('/LeftTreeMenu').init();
352                                                                                 
353                                                                                 this.get('/LeftTreeMenu').el.set_screen(Gdk.Screen.get_default());
354                                                                                 this.get('/LeftTreeMenu').el.show_all();
355                                                                                 this.get('/LeftTreeMenu').el.popup(null, null, null, null, 3, ev.button.time);
356                                                                                 print("click:" + res.path.to_string());
357                                                                                 return false;
358                                                                         },
359                                                                         "drag_begin":function (self, drag_context) {
360                                                                                 print('SOURCE: drag-begin');
361                                                                                  this.targetData = false;
362                                                                                 // find what is selected in our tree...
363                                                                                 var iter = new Gtk.TreeIter();
364                                                                                 var s = this.selection;
365                                                                                 s.get_selected(this.get('/LeftTree.model').el, iter);
366                                                                         
367                                                                                 // set some properties of the tree for use by the dropped element.
368                                                                                 var value = new GObject.Value('');
369                                                                                 this.get('/LeftTree.model').el.get_value(iter, 2, value);
370                                                                                 var data = JSON.parse(value.value);
371                                                                                 var xname = this.get('/LeftTree.model').file.guessName(data);
372                                                                                 
373                                                                                 this.el.dragData = xname;
374                                                                                 this.el.dropList = this.get('/LeftTree').getPaleteProvider().getDropList(xname);
375                                                                                 
376                                                                         
377                                                                                 // make the drag icon a picture of the node that was selected
378                                                                                 var path = this.get('/LeftTree.model').el.get_path(iter);
379                                                                                 this.el.treepath = path.to_string();
380                                                                                 
381                                                                                 var pix = this.el.create_row_drag_icon ( path);
382                                                                                 
383                                                                                 Gtk.drag_set_icon_pixmap (ctx,
384                                                                                     pix.get_colormap(),
385                                                                                     pix,
386                                                                                     null,
387                                                                                     -10,
388                                                                                     -10);
389                                                                                 
390                                                                                 return true;
391                                                                         },
392                                                                         "drag_end":function (self, drag_context) {
393                                                                                 Seed.print('LEFT-TREE: drag-end');
394                                                                                 this.el.dragData = false;
395                                                                                 this.el.dropList = false;
396                                                                                 this.targetData = false;
397                                                                                 this.get('/LeftTree.view').highlight(false);
398                                                                                 return true;
399                                                                         },
400                                                                         "drag_motion":function (self, ctx, x, y, time) {
401                                                                             console.log("LEFT-TREE: drag-motion");
402                                                                                         var src = Gtk.drag_get_source_widget(ctx);
403                                                                         
404                                                                                         // a drag from  elsewhere...- prevent drop..
405                                                                                         if (!src.dragData) {
406                                                                                             print("no drag data!");
407                                                                                             Gdk.drag_status(ctx, 0, time);
408                                                                                             this.targetData = false;
409                                                                                             return true;
410                                                                                         }
411                                                                                         var action = Gdk.DragAction.COPY;
412                                                                                         if (src == this.el) {
413                                                                                             // unless we are copying!!! ctl button..
414                                                                                             action = ctx.actions & Gdk.DragAction.MOVE ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY ;
415                                                                                         }
416                                                                                         var data = {};
417                                                                         
418                                                                                         if (!this.get('/LeftTree.model').el.iter_n_children(null)) {
419                                                                                                 // no children.. -- asume it's ok..
420                                                                                                 this.targetData =  [ '' , Gtk.TreeViewDropPosition.INTO_OR_AFTER , ''];
421                                                                                                 Gdk.drag_status(ctx, action ,time);
422                                                                                                 return true;
423                                                                                         }
424                                                                         
425                                                                                         print("GETTING POS");
426                                                                                         var isOver = this.get('/LeftTree.view').el.get_dest_row_at_pos(x,y, data);
427                                                                                         print("ISOVER? " + isOver);
428                                                                                         if (!isOver) {
429                                                                                             Gdk.drag_status(ctx, 0 ,time);
430                                                                                             return false; // not over apoint!?!
431                                                                                         }
432                                                                                         // drag node is parent of child..
433                                                                                         console.log("SRC TREEPATH: " + src.treepath);
434                                                                                         console.log("TARGET TREEPATH: " + data.path.to_string());
435                                                                                         
436                                                                                         // nned to check a  few here..
437                                                                                         //Gtk.TreeViewDropPosition.INTO_OR_AFTER
438                                                                                         //Gtk.TreeViewDropPosition.INTO_OR_BEFORE
439                                                                                         //Gtk.TreeViewDropPosition.AFTER
440                                                                                         //Gtk.TreeViewDropPosition.BEFORE
441                                                                                         
442                                                                                         if (typeof(src.treepath) != 'undefined'  && 
443                                                                                             src.treepath == data.path.to_string().substring(0,src.treepath.length)) {
444                                                                                             print("subpath drag");
445                                                                                              Gdk.drag_status(ctx, 0 ,time);
446                                                                                             return false;
447                                                                                         }
448                                                                                         
449                                                                                         // check that 
450                                                                                         //print("DUMPING DATA");
451                                                                                         //console.dump(data);
452                                                                                         // path, pos
453                                                                                         
454                                                                                         print(data.path.to_string() +' => '+  data.pos);
455                                                                                         var tg = this.get('/LeftTree.model').findDropNodeByPath(
456                                                                                             data.path.to_string(), src.dropList, data.pos);
457                                                                                             
458                                                                                         this.get('/LeftTree.view').highlight(tg);
459                                                                                         if (!tg.length) {
460                                                                                             print("Can not find drop node path");
461                                                                                             this.targetData = false;
462                                                                                             Gdk.drag_status(ctx, 0, time);
463                                                                                             return true;
464                                                                                         }
465                                                                                         //console.dump(tg);
466                                                                                         this.targetData = tg;    
467                                                                                         
468                                                                                         
469                                                                                         Gdk.drag_status(ctx, action ,time);
470                                                                                          
471                                                                                         return true;
472                                                                         },
473                                                                         "drag_drop":function (w, ctx, x, y, time) {
474                                                                               Seed.print("TARGET: drag-drop");
475                                                                                                
476                                                                                                 Gtk.drag_get_data
477                                                                                                 (
478                                                                                                         w,         /* will receive 'drag-data-received' signal */
479                                                                                                         ctx,        /* represents the current state of the DnD */
480                                                                                                         this.get('/Window').atoms["STRING"],    /* the target type we want */
481                                                                                                         time            /* time stamp */
482                                                                                                 );
483                                                                                                 
484                                                                                                  
485                                                                                                 /* No target offered by source => error */
486                                                                                                
487                                                                         
488                                                                                                 return  true;
489                                                                         },
490                                                                         "drag_data_received":function (self, ctx, x, y, sel_data, info, time) {
491                                                                                  print("Tree: drag-data-received");
492                                                                         
493                                                                                       var   delete_selection_data = false;
494                                                                                        var  dnd_success = false;
495                                                                                         /* Deal with what we are given from source */
496                                                                                         if( sel_data && sel_data.length ) {
497                                                                                             
498                                                                                             if (ctx.action == Gdk.DragAction.ASK)  {
499                                                                                                 /* Ask the user to move or copy, then set the ctx action. */
500                                                                                             }
501                                                                         
502                                                                                             if (ctx.action == Gdk.DragAction.MOVE) {
503                                                                                                 //delete_selection_data = true;
504                                                                                             }
505                                                                                             
506                                                                                             var source = Gtk.drag_get_source_widget(ctx);
507                                                                         
508                                                                                             if (this.targetData) {
509                                                                                                 if (source != this.el) {
510                                                                                                     this.get('/LeftTree.model').dropNode(this.targetData,  source.dragData);
511                                                                                                 } else {
512                                                                                                     // drag around.. - reorder..
513                                                                                                      this.get('/LeftTree.model').moveNode(this.targetData, ctx.action);
514                                                                                                     
515                                                                                                     
516                                                                                                 }
517                                                                                                 //Seed.print(this.targetData);
518                                                                                               
519                                                                                             }
520                                                                                             
521                                                                                             
522                                                                                             
523                                                                                             // we can send stuff to souce here...
524                                                                         
525                                                                                             dnd_success = true;
526                                                                         
527                                                                                         }
528                                                                         
529                                                                                         if (dnd_success == false)
530                                                                                         {
531                                                                                                 Seed.print ("DnD data transfer failed!\n");
532                                                                                         }
533                                                                         
534                                                                                         Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
535                                                                                         return true;
536                                                                         },
537                                                                         "cursor_changed":function (self) {
538                                                                              if (this.blockChanges) { // probably not needed.. 
539                                                                                return true;
540                                                                              }
541                                                                              var render = this.get('/LeftTree').getRenderer();                
542                                                                            
543                                                                             
544                                                                             if (this.selection.count_selected_rows() < 1) {
545                                                                                 this.get('/LeftPanel.model').load( false);
546                                                                                 this.get('/MidPropTree').activeElement =  false;
547                                                                                 this.get('/MidPropTree').hideWin();
548                                                                         
549                                                                                 var pm = this.get('/RightPalete.model');
550                                                                                 if (!this.get('/LeftTree').getPaleteProvider()) {
551                                                                                     // it may not be loaded yet..
552                                                                                     return  true;
553                                                                                 }
554                                                                                 pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(
555                                                                                     this.get('/LeftTree.model').listAllTypes()));
556                                                                                 if (render && render.redraw) {
557                                                                                     render.redraw();
558                                                                                 }
559                                                                                 return true;
560                                                                             }
561                                                                                     
562                                                                                     //console.log('changed');
563                                                                                 var s = this.selection;
564                                                                                   var iter = new Gtk.TreeIter();
565                                                                                 s.get_selected(this.get('/LeftTree.model').el, iter);
566                                                                                 
567                                                                                 
568                                                                                 // var val = "";
569                                                                                 value = new GObject.Value('');
570                                                                                 this.get('/LeftTree.model').el.get_value(iter, 2, value);
571                                                                                 this.get('/LeftTree.model').activePath = this.get('/LeftTree.model').el.get_path(iter).to_string();
572                                                                                 
573                                                                                 var data = JSON.parse(value.value);
574                                                                                 this.get('/MidPropTree').activeElement =  data;
575                                                                                 this.get('/MidPropTree').hideWin();
576                                                                                 this.get('/LeftPanel.model').load( data);
577                                                                                 
578                                                                                 console.log(value.value);
579                                                                                // _g.button.set_label(''+value.get_string());
580                                                                         
581                                                                                 var pm =this.get('/RightPalete.model');
582                                                                                 pm.load( this.get('/RightPalete').provider.gatherList(
583                                                                                      this.get('/LeftTree.model').listAllTypes()));
584                                                                                
585                                                                                 
586                                                                                    if (render && render.redraw) {
587                                                                                     render.redraw();
588                                                                                 }
589                                                                                    
590                                                                                     //Seed.print( value.get_string());
591                                                                                     return true;
592                                                                                         
593                                                                         }
594                                                                     },
595                                                                     items : [
596                                                                         {
597                                                                             xtype: Gtk.TreeStore,
598                                                                             pack : "set_model",
599                                                                             id : "model",
600                                                                             init : function() {
601                                                                                 XObject.prototype.init.call(this);
602                                                                              this.el.set_column_types ( 3, [
603                                                                                         GObject.TYPE_STRING, // title 
604                                                                                         GObject.TYPE_STRING, // tip
605                                                                                         GObject.TYPE_STRING // source..
606                                                                                         ] );
607                                                                             },
608                                                                             activePath : false,
609                                                                             changed : function(n, refresh) {
610                                                                                      print("MODEL CHANGED CALLED" + this.activePath);
611                                                                                      if (this.activePath) {
612                                                                                         var iter = new Gtk.TreeIter();
613                                                                                         this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath))
614                                                                                         this.el.set_value(iter, 0, [GObject.TYPE_STRING, this.nodeTitle(n)]);
615                                                                                         this.el.set_value(iter, 1, [GObject.TYPE_STRING, this.nodeTitle(n)]);
616                                                                                         
617                                                                                         this.el.set_value(iter, 2, [GObject.TYPE_STRING, this.nodeToJSON(n)]);
618                                                                                     }
619                                                                                         //this.currentTree = this.toJS(false, true)[0];
620                                                                                     this.file.items = this.toJS(false, false);
621                                                                                     print("AFTER CHANGED");
622                                                                                     //console.dump(this.file.items);
623                                                                                     this.file.save();
624                                                                                     this.currentTree = this.file.items[0];
625                                                                                     //console.log(this.file.toSource());
626                                                                                     
627                                                                                     if (refresh) {
628                                                                                         print("REDNER BROWSER?!");
629                                                                                         this.get('/LeftTree').renderView();
630                                                                             
631                                                                                         var pm = this.get('/RightPalete.model');
632                                                                                         if (!this.get('/RightPalete').provider) {
633                                                                                             pm.load([]);
634                                                                                             return;
635                                                                                         }
636                                                                                         
637                                                                                         
638                                                                                         pm.load( this.get('/RightPalete').provider.gatherList(this.listAllTypes()));
639                                                                                         //imports['Builder/RightBrowser.js'].renderJS(this.toJS());
640                                                                                     }
641                                                                                           
642                                                                             },
643                                                                             loadFile : function(f) {
644                                                                                 //console.dump(f);
645                                                                                         this.el.clear();
646                                                                                         this.file = f;
647                                                                                         
648                                                                                         if (!f) {
649                                                                                             console.log('missing file');
650                                                                                             return;
651                                                                                         }
652                                                                                         
653                                                                                         // load the file if not loaded..
654                                                                                         if (f.items === false) {
655                                                                                             var _this = this;
656                                                                                             f.loadItems(function() {
657                                                                                                 _this.loadFile(f);
658                                                                                             });
659                                                                                             return;
660                                                                                             
661                                                                                         }
662                                                                                         if (f.items.length && typeof(f.items[0]) == 'string') {
663                                                                                         
664                                                                                             this.get('/RightEditor').el.show();
665                                                                                             this.get('/RightEditor.view').load( f.items[0]);
666                                                                                             return;
667                                                                                         }
668                                                                                         print("LOAD");
669                                                                                         //console.dump(f.items);
670                                                                                         this.load(f.items);
671                                                                                         this.get('/LeftTree.view').el.expand_all();
672                                                                             
673                                                                                         if (!f.items.length) {
674                                                                                             // single item..
675                                                                                             
676                                                                                             this.get('/Window.leftvpaned').el.set_position(80);
677                                                                                             // select first...
678                                                                                             this.get('/LeftTree.view').el.set_cursor( 
679                                                                                                 new  Gtk.TreePath.from_string('0'), null, false);
680                                                                                             
681                                                                                             
682                                                                                         } else {
683                                                                                               this.get('/Window.leftvpaned').el.set_position(200);
684                                                                                         }
685                                                                                         
686                                                                                         
687                                                                                         //print("hide right editior");
688                                                                                         this.get('/RightEditor').el.hide();
689                                                                                         //print("set current tree");
690                                                                                         this.currentTree = this.toJS(false, false)[0];
691                                                                                         //console.dump(this.currentTree);
692                                                                                         this.currentTree = this.currentTree || { items: [] };
693                                                                                         this.get('/LeftTree').renderView();
694                                                                                         //console.dump(this.map);
695                                                                                         //var RightPalete     = imports.Builder.RightPalete.RightPalete;
696                                                                                         var pm = this.get('/RightPalete.model');
697                                                                                         // set up provider..
698                                                                                         
699                                                                                         this.get('/RightPalete').provider = this.get('/LeftTree').getPaleteProvider();
700                                                                                         
701                                                                                         if (!this.get('/RightPalete').provider) {
702                                                                                             print ("********* PALETE PROVIDER MISSING?!!");
703                                                                                         }
704                                                                                         this.get('/LeftTree').renderView();
705                                                                                         
706                                                                                         pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(this.listAllTypes()));
707                                                                                         
708                                                                                         
709                                                                                                 
710                                                                                         this.get('/Window.view-notebook').el.set_current_page(
711                                                                                             this.get('/LeftTree.model').file.getType()== 'Roo' ? 0 : -1);
712                                                                                                 
713                                                                             },
714                                                                             findDropNode : function(treepath_str, targets) {
715                                                                             
716                                                                             // this is used by the dragdrop code in the roo version AFAIR..
717                                                                             
718                                                                                                 var path = treepath_str.replace(/^builder-/, '');
719                                                                                         // treemap is depreciated... - should really check if model has any entries..
720                                                                             
721                                                                                         if (!this.el.iter_n_children(null)) {
722                                                                                             print("NO KEYS");
723                                                                                             return [ '',  Gtk.TreeViewDropPosition.INTO_OR_AFTER];
724                                                                                         }
725                                                                                         print("FIND treepath: " + path);
726                                                                                         //console.dump(this.treemap);
727                                                                                         
728                                                                                         if (!treepath_str.match(/^builder-/)) {
729                                                                                             return []; // nothing!
730                                                                                         }
731                                                                                         if (targets === true) {
732                                                                                             return [ path ];
733                                                                                         }
734                                                                                         return this.findDropNodeByPath(path,targets) 
735                                                                             },
736                                                                             findDropNodeByPath : function(treepath_str, targets, pref) {
737                                                                                 var path = treepath_str + ''; // dupe it..
738                                                                                 pref = typeof(pref) == 'undefined' ?  Gtk.TreeViewDropPosition.INTO_OR_AFTER : pref;
739                                                                                 var last = false;
740                                                                                 //console.dump(this.treemap);
741                                                                                 while (path.length) {
742                                                                                     print("LOOKING FOR PATH: " + path);
743                                                                                     var node_data = this.singleNodeToJS(path);
744                                                                                     if (node_data === false) {
745                                                                                         print("node not found");
746                                                                                         return [];
747                                                                                     }
748                                                                                     
749                                                                                     var xname = this.get('/LeftTree.model').file.guessName(node_data);
750                                                                                     var match = false;
751                                                                                     var prop = '';
752                                                                                     targets.forEach(function(tg) {
753                                                                                         if (match) {
754                                                                                             return;;
755                                                                                         }
756                                                                                         if ((tg == xname)  ) {
757                                                                                             match = tg;
758                                                                                         }
759                                                                                         if (tg.indexOf(xname +':') === 0) {
760                                                                                             match = tg;
761                                                                                             prop = tg.split(':').pop();
762                                                                                         }
763                                                                                     });
764                                                                                     
765                                                                                     if (match) {
766                                                                                         if (last) { // pref is after/before..
767                                                                                             // then it's after last
768                                                                                             if (pref > 1) {
769                                                                                                 return []; // do not allow..
770                                                                                             }
771                                                                                             return [ last, pref , prop];
772                                                                                             
773                                                                                         }
774                                                                                         return [ path , Gtk.TreeViewDropPosition.INTO_OR_AFTER , prop];
775                                                                                     }
776                                                                                     var par = path.split(':');
777                                                                                     last = path;
778                                                                                     par.pop();
779                                                                                     path = par.join(':');
780                                                                                 }
781                                                                                 
782                                                                                 return [];
783                                                                                         
784                                                                             },
785                                                                             dropNode : function(target_data, node) {
786                                                                               print("drop Node");
787                                                                                   console.dump(node);
788                                                                                   console.dump(target_data);
789                                                                                         var tp = target_data[0].length ? new  Gtk.TreePath.from_string( target_data[0] ) : false;
790                                                                                         
791                                                                                         print("add " + tp + "@" + target_data[1]  );
792                                                                                         var parent = tp;
793                                                                                         var after = false;
794                                                                                         if (tp && target_data[1]  < 2) { // before or after..
795                                                                                             var ar = target_data[0].split(':');
796                                                                                             ar.pop();
797                                                                                             parent  = new  Gtk.TreePath.from_string( ar.join(':') );
798                                                                                             after = tp;
799                                                                                         }
800                                                                                         var n_iter = new Gtk.TreeIter();
801                                                                                         var iter_par = new Gtk.TreeIter();
802                                                                                         var iter_after = after ? new Gtk.TreeIter() : false;
803                                                                                         
804                                                                                         
805                                                                                         
806                                                                                         if (parent !== false) {
807                                                                                             this.el.get_iter(iter_par, parent);
808                                                                                         } else {
809                                                                                             iter_par = null;
810                                                                                         }
811                                                                                         
812                                                                                         
813                                                                                         if (tp && after) {
814                                                                                             print(target_data[1]  > 0 ? 'insert_after' : 'insert_before');
815                                                                                             this.el.get_iter(iter_after, after);
816                                                                                             this.el[ target_data[1]  > 0 ? 'insert_after' : 'insert_before'](
817                                                                                                     n_iter, iter_par, iter_after);
818                                                                                             
819                                                                                         } else {
820                                                                                             this.el.append(n_iter, iter_par);
821                                                                                             
822                                                                                         }
823                                                                                         
824                                                                                         if (typeof(node) == 'string') {
825                                                                                             var ar = node.split('.');
826                                                                                             var xtype = ar.pop();
827                                                                                             
828                                                                                             node = {
829                                                                                                 '|xns' : ar.join('.'),
830                                                                                                 'xtype' : xtype
831                                                                                             };
832                                                                                             if (target_data.length == 3 && target_data[2].length) {
833                                                                                                 node['*prop'] = target_data[2];
834                                                                                             }
835                                                                                             
836                                                                                         }
837                                                                                         // work out what kind of packing to use..
838                                                                                         if (typeof(node.pack) == 'undefined'  && parent !== false) {
839                                                                                             var pal = this.get('/LeftTree').getPaleteProvider();
840                                                                                             
841                                                                                             var pname = pal.guessName(this.singleNodeToJS(parent.to_string()));
842                                                                                             print ("PNAME : "  + pname);
843                                                                                             var cname = pal.guessName(node);
844                                                                                             print ("CNAME : "  + cname);
845                                                                                             node.pack = pal.getDefaultPack(pname, cname);
846                                                                                             
847                                                                                             
848                                                                                         }
849                                                                                         
850                                                                                         
851                                                                                         var xitems = [];
852                                                                                         if (node.items) {
853                                                                                             xitems = node.items;
854                                                                                             delete node.items;
855                                                                                         }
856                                                                             // load children - if it has any..
857                                                                             
858                                                                                         if (xitems) {
859                                                                                             this.load(xitems, n_iter);
860                                                                                         }
861                                                                                         if (tp && (xitems || after)) {
862                                                                                             this.get('/LeftTree.view').el.expand_row(this.el.get_path(iter_par), true);
863                                                                                         }
864                                                                                         // wee need to get the empty proptypes from somewhere..
865                                                                                         
866                                                                                         //var olditer = this.activeIter;
867                                                                                         this.activePath = this.el.get_path(n_iter).to_string();
868                                                                             
869                                                                                   // changed actually set's the node data..
870                                                                                         this.changed(node, true);
871                                                                                         
872                                                                                         
873                                                                                         
874                                                                                         this.get('/LeftTree.view').el.set_cursor(this.el.get_path(n_iter), null, false);
875                                                                                         
876                                                                                         //Builder.MidPropTree._model.load(node);
877                                                                                         //Builder.MidPropTree._win.hideWin();
878                                                                                         //Builder.LeftPanel._model.load( node);
879                                                                                         
880                                                                                         
881                                                                             },
882                                                                             moveNode : function(target_data, action) {
883                                                                                  //print("MOVE NODE");
884                                                                                        // console.dump(target_data);
885                                                                                         var old_iter = new Gtk.TreeIter();
886                                                                                         var s = this.get('/LeftTree.view').selection;
887                                                                                         s.get_selected(this.el, old_iter);
888                                                                                         var node = this.nodeToJS(old_iter,false);
889                                                                                         //console.dump(node);
890                                                                                         
891                                                                                         
892                                                                                         // needs to drop first, otherwise the target_data 
893                                                                                         // treepath will be invalid.
894                                                                                         
895                                                                                         this.dropNode(target_data, node);
896                                                                                   if (action & Gdk.DragAction.MOVE) {
897                                                                                                   //          print("REMOVING OLD NODE");
898                                                                                                             this.el.remove(old_iter);
899                                                                                                             
900                                                                                         }
901                                                                                         
902                                                                                         this.activePath= false;
903                                                                                         this.changed(false,true);
904                                                                             },
905                                                                             deleteSelected : function() {
906                                                                                         this.get('/LeftTree.view').blockChanges = true;
907                                                                                         var old_iter = new Gtk.TreeIter();
908                                                                                         var s = this.get('/LeftTree.view').selection;
909                                                                                         s.get_selected(this.el, old_iter);
910                                                                                         var path = this.el.get_path(old_iter).to_string();
911                                                                             
912                                                                                         this.activePath= false;      
913                                                                                         s.unselect_all();
914                                                                             
915                                                                                         this.activePath= false;      
916                                                                                     var iter = new Gtk.TreeIter();
917                                                                                         this.el.get_iter_from_string(iter, path);
918                                                                                         this.el.remove(iter);
919                                                                                         
920                                                                                         // rebuild treemap. -- depreciated.!!
921                                                                                         this.map = {};
922                                                                                         this.treemap = { };
923                                                                                         //this.toJS(null, true) // does not do anything?
924                                                                                     this.activePath= false;      
925                                                                                         this.changed(false,true);
926                                                                                       this.get('/LeftTree.view').blockChanges = false;
927                                                                             },
928                                                                             currentTree : false,
929                                                                             listAllTypes : function() {
930                                                                                 var s = this.get('/LeftTree.view').selection;
931                                                                                 print ("LIST ALL TYPES: " + s.count_selected_rows() );
932                                                                                 
933                                                                                 if (s.count_selected_rows() > 0) {
934                                                                                     var iter = new Gtk.TreeIter();    
935                                                                                     s.get_selected(this.el, iter);
936                                                                             
937                                                                                     // set some properties of the tree for use by the dropped element.
938                                                                                     var value = new GObject.Value('');
939                                                                                     this.el.get_value(iter, 2, value);
940                                                                                     var data = JSON.parse(value.value);
941                                                                                     
942                                                                                     
943                                                                                     var xname = this.get('/LeftTree.model').file.guessName(data);
944                                                                                     console.log('selected:' + xname);
945                                                                                     if (xname.length) {
946                                                                                         return [ xname ];
947                                                                                     }
948                                                                                     return []; // could not find it..
949                                                                                 }
950                                                                                 
951                                                                                 var ret = [ ];
952                                                                                 
953                                                                                var _this = this;
954                                                                                 function addall(li)
955                                                                                 {
956                                                                                     li.forEach(function(el) {
957                                                                                         // this is specific to roo!!!?
958                                                                                         
959                                                                                         var fullpath =  _this.file.guessName(el);
960                                                                                         if (fullpath.length && ret.indexOf(fullpath) < 0) {
961                                                                                             ret.push(fullpath);
962                                                                                         }
963                                                                                         
964                                                                                         
965                                                                                         if (el.items && el.items.length) {
966                                                                                             addall(el.items);
967                                                                                         }
968                                                                                         
969                                                                                     });
970                                                                                     
971                                                                                     
972                                                                                 }
973                                                                                 
974                                                                                 addall([this.currentTree]);
975                                                                                 
976                                                                                 // only if we have nothing, should we add '*top'
977                                                                                 if (!ret.length) {
978                                                                                     ret = [ '*top' ];
979                                                                                 }
980                                                                                 //console.log('all types in tree');
981                                                                                 //console.dump(ret);
982                                                                                 
983                                                                                 return ret;
984                                                                                                         
985                                                                             },
986                                                                             singleNodeToJS : function (treepath) 
987                                                                                     {
988                                                                                         var iter = new Gtk.TreeIter(); 
989                                                                                         if (!this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath))) {
990                                                                                             return false;
991                                                                                         }
992                                                                                         
993                                                                                         var iv = this.getIterValue(iter, 2);
994                                                                                        
995                                                                                         return JSON.parse(iv);
996                                                                                         
997                                                                                     },
998                                                                             nodeToJS : function (iter, with_id) 
999                                                                             {
1000                                                                                 var par = new Gtk.TreeIter(); 
1001                                                                                 var iv = this.getIterValue(iter, 2);
1002                                                                                // print("IV" + iv);
1003                                                                                 var k = JSON.parse(iv);
1004                                                                                 if (k.json && !this.el.iter_parent( par, iter  )) {
1005                                                                                     delete k.json;
1006                                                                                 }
1007                                                                                 
1008                                                                                 if (with_id) {
1009                                                                                     var treepath_str = this.el.get_path(iter).to_string();
1010                                                                                     // not sure how we can handle mixed id stuff..
1011                                                                                     if (typeof(k.id) == 'undefined')  {
1012                                                                                         k.id =  'builder-'+ treepath_str ;
1013                                                                                     }
1014                                                                                     
1015                                                                                     // needed??
1016                                                                                     this.treemap[  treepath_str ] = k;
1017                                                                                     k.xtreepath = treepath_str ;
1018                                                                                     
1019                                                                                 }
1020                                                                                 if (this.el.iter_has_child(iter)) {
1021                                                                                     citer = new Gtk.TreeIter();
1022                                                                                     this.el.iter_children(citer, iter);
1023                                                                                     k.items = this.toJS(citer,with_id);
1024                                                                                 }
1025                                                                                 return k;
1026                                                                             },
1027                                                                             toJS : function(iter, with_id)
1028                                                                                     {
1029                                                                                         //Seed.print("WITHID: "+ with_id);
1030                                                                                         
1031                                                                                         var first = false;
1032                                                                                         if (!iter) {
1033                                                                                             
1034                                                                                             this.treemap = { }; 
1035                                                                                             
1036                                                                                             iter = new Gtk.TreeIter();
1037                                                                                             if (!this.el.get_iter_first(iter)) {
1038                                                                                                 return [];
1039                                                                                             }
1040                                                                                             first = true;
1041                                                                                         } 
1042                                                                                         
1043                                                                                         var ar = [];
1044                                                                                            
1045                                                                                         while (true) {
1046                                                                                             
1047                                                                                             var k = this.nodeToJS(iter, with_id); 
1048                                                                                             ar.push(k);
1049                                                                                             
1050                                                                                             
1051                                                                                             if (!this.el.iter_next(iter)) {
1052                                                                                                 break;
1053                                                                                             }
1054                                                                                         }
1055                                                                                         
1056                                                                                         return ar;
1057                                                                                         // convert the list into a json string..
1058                                                                                     
1059                                                                                         
1060                                                                                     },
1061                                                                             getIterValue : function (iter, col) {
1062                                                                                 var gval = new GObject.Value('');
1063                                                                                 this.el.get_value(iter, col ,gval);
1064                                                                                 return  gval.value;
1065                                                                                 
1066                                                                                 
1067                                                                             },
1068                                                                             nodeTitle : function(c) {
1069                                                                                   var txt = [];
1070                                                                                 c = c || {};
1071                                                                                 var sr = (typeof(c['+buildershow']) != 'undefined') &&  !c['+buildershow'] ? true : false;
1072                                                                                 if (sr) txt.push('<s>');
1073                                                                                 if (typeof(c['*prop']) != 'undefined')   { txt.push(c['*prop']+ ':'); }
1074                                                                                 if (c.xtype)      { txt.push(c.xtype); }
1075                                                                                 if (c.id)      { txt.push('<b>[id=' + c.id + ']</b>'); }
1076                                                                                 if (c.fieldLabel) { txt.push('[' + c.fieldLabel + ']'); }
1077                                                                                 if (c.boxLabel)   { txt.push('[' + c.boxLabel + ']'); }
1078                                                                                 
1079                                                                                 
1080                                                                                 if (c.layout)     { txt.push('<i>' + c.layout + '</i>'); }
1081                                                                                 if (c.title)      { txt.push('<b>' + c.title + '</b>'); }
1082                                                                                 if (c.label)      { txt.push('<b>' + c.label+ '</b>'); }
1083                                                                                 if (c.header)    { txt.push('<b>' + c.header + '</b>'); }
1084                                                                                 if (c.legend)      { txt.push('<b>' + c.legend + '</b>'); }
1085                                                                                 if (c.text)       { txt.push('<b>' + c.text + '</b>'); }
1086                                                                                 if (c.name)       { txt.push('<b>' + c.name+ '</b>'); }
1087                                                                                 if (c.region)     { txt.push('<i>(' + c.region + ')</i>'); }
1088                                                                                 if (c.dataIndex) { txt.push('[' + c.dataIndex+ ']'); }
1089                                                                                 
1090                                                                                 // for flat classes...
1091                                                                                 if (typeof(c['*class']) != 'undefined')  { txt.push('<b>' +  c['*class']+  '</b>'); }
1092                                                                                 if (typeof(c['*extends']) != 'undefined')  { txt.push(': <i>' +  c['*extends']+  '</i>'); }
1093                                                                                 
1094                                                                                 
1095                                                                                 if (sr) txt.push('</s>');
1096                                                                                 return (txt.length == 0 ? "Element" : txt.join(" "));
1097                                                                             },
1098                                                                             nodeToJSON : function(c) {
1099                                                                                 var o  = {}
1100                                                                                 for (var i in c) {
1101                                                                                     if (i == 'items') {
1102                                                                                          continue;
1103                                                                                     }
1104                                                                                     o[i] = c[i];
1105                                                                                 }
1106                                                                                 return JSON.stringify(o);
1107                                                                             },
1108                                                                             load : function(tr,iter)
1109                                                                                     {
1110                                                                                         var citer = new Gtk.TreeIter();
1111                                                                                         //this.insert(citer,iter,0);
1112                                                                                         for(var i =0 ; i < tr.length; i++) {
1113                                                                                             if (iter) {
1114                                                                                                 this.el.insert(citer,iter,-1);
1115                                                                                             } else {
1116                                                                                                 this.el.append(citer);
1117                                                                                             }
1118                                                                                             
1119                                                                                             this.el.set_value(citer, 0, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);
1120                                                                                             this.el.set_value(citer, 1, [GObject.TYPE_STRING, this.nodeTip(tr[i]) ]);
1121                                                                                             this.el.set_value(citer, 2, [GObject.TYPE_STRING, this.nodeToJSON(tr[i])]);
1122                                                                                             if (tr[i].items && tr[i].items.length) {
1123                                                                                                 this.load(tr[i].items, citer);
1124                                                                                             }
1125                                                                                         }     
1126                                                                                     },
1127                                                                             nodeTip : function(c) {
1128                                                                                 var ret = this.nodeTitle(c);
1129                                                                                 var funcs = '';
1130                                                                             
1131                                                                                 
1132                                                                                 for( var i in c) {
1133                                                                             
1134                                                                                     if (!i.length || i[0] != '|') {
1135                                                                                         continue;
1136                                                                                     }
1137                                                                                     if (i == '|init') { 
1138                                                                                         continue;
1139                                                                                     }
1140                                                                                     if (typeof(c[i]) != 'string') {
1141                                                                                        continue;
1142                                                                                     }
1143                                                                                     //print("prop : " + i + ':' + c[i]);
1144                                                                                     if (!c[i].match(new RegExp('function'))) {
1145                                                                                         continue;
1146                                                                                     }
1147                                                                                     funcs += "\n<b>" + i.substring(1) + '</b> : ' + c[i].split(/\n/).shift();
1148                                                                                         
1149                                                                                 }
1150                                                                                 if (funcs.length) {
1151                                                                                     ret+="\n\nMethods:" + funcs;
1152                                                                                 }
1153                                                                                 return ret;
1154                                                                                 
1155                                                                             }
1156                                                                         },
1157                                                                         {
1158                                                                             xtype: Gtk.TreeViewColumn,
1159                                                                             pack : "append_column",
1160                                                                             init : function() {
1161                                                                                 XObject.prototype.init.call(this);
1162                                                                                this.el.add_attribute(this.items[0].el , 'markup', 0 );
1163                                                                             },
1164                                                                             items : [
1165                                                                                 {
1166                                                                                     xtype: Gtk.CellRendererText,
1167                                                                                     pack : "pack_start"
1168                                                                                 }
1169                                                                             ]
1170                                                                         }
1171                                                                     ]
1172                                                                 },
1173                                                                 {
1174                                                                     xtype: Gtk.Menu,
1175                                                                     pack : false,
1176                                                                     id : "LeftTreeMenu",
1177                                                                     items : [
1178                                                                         {
1179                                                                             xtype: Gtk.MenuItem,
1180                                                                             pack : "add",
1181                                                                             label : "Delete Element",
1182                                                                             listeners : {
1183                                                                                 "activate":function (self) {
1184                                                                                 
1185                                                                                      this.get('/LeftTree.model').deleteSelected();
1186                                                                                 }
1187                                                                             }
1188                                                                         }
1189                                                                     ]
1190                                                                 }
1191                                                             ]
1192                                                         },
1193                                                         {
1194                                                             xtype: Gtk.VBox,
1195                                                             pack : "add",
1196                                                             id : "LeftProjectTree",
1197                                                             showNoProjectSelected : function() {
1198                                                                this.get('/StandardErrorDialog').show("Select a Project first."); 
1199                                                             },
1200                                                             getActiveProject : function() {
1201                                                                  return this.project;
1202                                                             },
1203                                                             listeners : {
1204                                                                 "leave_notify_event":function (self, event) {
1205                                                                     return false;
1206                                                                 }
1207                                                             },
1208                                                             items : [
1209                                                                 {
1210                                                                     xtype: Gtk.HBox,
1211                                                                     pack : "pack_start,false,false",
1212                                                                     items : [
1213                                                                         {
1214                                                                             xtype: Gtk.ComboBox,
1215                                                                             id : "combo",
1216                                                                             init : function() {
1217                                                                                 XObject.prototype.init.call(this);
1218                                                                                 this.el.add_attribute(this.get('render').el , 'markup', 1 );  
1219                                                                             },
1220                                                                             getValue : function() {
1221                                                                                 var ix = this.el.get_active();
1222                                                                                 if (ix < 0 ) {
1223                                                                                     return false;
1224                                                                                 }
1225                                                                                 var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
1226                                                                                 if (typeof(data[ix]) == 'undefined') {
1227                                                                                 return false; 
1228                                                                                 }
1229                                                                                 return data[ix].fn;
1230                                                                             },
1231                                                                             setValue : function(fn)
1232                                                                             {
1233                                                                                 var el = this.el;
1234                                                                                 el.set_active(-1);
1235                                                                                 var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
1236                                                                                 data.forEach(function(n, ix) {
1237                                                                                     if (fn == n.fn) {
1238                                                                                         el.set_active(ix);
1239                                                                                         return false;
1240                                                                                     }
1241                                                                                 });
1242                                                                             },
1243                                                                             listeners : {
1244                                                                                 "changed":function (self) {
1245                                                                                         var fn = this.getValue();
1246                                                                                         var pm  = imports.Builder.Provider.ProjectManager.ProjectManager;
1247                                                                                         this.get('/LeftProjectTree.model').loadProject(pm.getByFn(fn))
1248                                                                                 }
1249                                                                             },
1250                                                                             items : [
1251                                                                                 {
1252                                                                                     xtype: Gtk.CellRendererText,
1253                                                                                     pack : "pack_start,true",
1254                                                                                     id : "render"
1255                                                                                 },
1256                                                                                 {
1257                                                                                     xtype: Gtk.ListStore,
1258                                                                                     pack : "set_model",
1259                                                                                     init : function() {
1260                                                                                         XObject.prototype.init.call(this);
1261                                                                                       this.el.set_column_types ( 2, [
1262                                                                                             GObject.TYPE_STRING,  // real key
1263                                                                                             GObject.TYPE_STRING // real type
1264                                                                                             
1265                                                                                             
1266                                                                                         ] );
1267                                                                                        var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
1268                                                                                        var _this = this;
1269                                                                                        pm.on('changed', function() {
1270                                                                                            print("caught changed hook on project manager - reloading data");
1271                                                                                         _this.loadData(pm.projects);
1272                                                                                     
1273                                                                                        });
1274                                                                                     },
1275                                                                                     loadData : function(data) {
1276                                                                                          var ov = this.get('/LeftProjectTree.combo').getValue();
1277                                                                                         this.el.clear();
1278                                                                                         var iter = new Gtk.TreeIter();
1279                                                                                         var el = this.el;
1280                                                                                         data.forEach(function(p) {
1281                                                                                             
1282                                                                                             el.append(iter);
1283                                                                                             
1284                                                                                              
1285                                                                                             el.set_value(iter, 0, p.fn);
1286                                                                                             el.set_value(iter, 1, p.name);
1287                                                                                             
1288                                                                                         });
1289                                                                                         
1290                                                                                         this.get('/LeftProjectTree.combo').setValue(ov);
1291                                                                                     },
1292                                                                                     id : "combomodel"
1293                                                                                 }
1294                                                                             ]
1295                                                                         }
1296                                                                     ]
1297                                                                 },
1298                                                                 {
1299                                                                     xtype: Gtk.ScrolledWindow,
1300                                                                     pack : "add",
1301                                                                     shadow_type : Gtk.ShadowType.IN,
1302                                                                     init : function() {
1303                                                                         XObject.prototype.init.call(this);
1304                                                                         this.el.set_policy  (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC );
1305                                                                     },
1306                                                                     items : [
1307                                                                         {
1308                                                                             xtype: Gtk.TreeView,
1309                                                                             headers_visible : false,
1310                                                                             enable_tree_lines : true,
1311                                                                             tooltip_column : 1,
1312                                                                             init : function() {
1313                                                                                 XObject.prototype.init.call(this);
1314                                                                             var description = new Pango.FontDescription.c_new();
1315                                                                                                         description.set_size(8000);
1316                                                                                                         this.el.modify_font(description);
1317                                                                                                         
1318                                                                                                         this.selection = this.el.get_selection();
1319                                                                                                         this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1320                                                                             },
1321                                                                             id : "view",
1322                                                                             listeners : {
1323                                                                                 "cursor_changed":function (self) {
1324                                                                                         var iter = new Gtk.TreeIter();
1325                                                                                                                 
1326                                                                                         if (this.selection.count_selected_rows() < 1) {
1327                                                                                             //XN.get('Builder.LeftTree.model').
1328                                                                                             this.get('/LeftTree.model').load( false);
1329                                                                                             
1330                                                                                             return;
1331                                                                                         }
1332                                                                                         var model = this.get('/LeftProjectTree.model');
1333                                                                                         //console.log('changed');
1334                                                                                         var s = this.selection;
1335                                                                                         s.get_selected(model, iter);
1336                                                                                         value = new GObject.Value('');
1337                                                                                         model.el.get_value(iter, 2, value);
1338                                                                                         
1339                                                                                         console.log(value.value);// id..
1340                                                                                         
1341                                                                                         var file = this.get('/LeftProjectTree').project.getById(value.value);
1342                                                                                         
1343                                                                                         
1344                                                                                         console.log(file);
1345                                                                                         
1346                                                                                 
1347                                                                                 
1348                                                                                         var nb = this.get('/LeftTopPanel.expander');
1349                                                                                         nb.el.expanded = false;
1350                                                                                         nb.listeners.activate.call(nb);
1351                                                                                         //_expander.el.set_expanded(false);
1352                                                                                 
1353                                                                                         var ltm = this.get('/LeftTree.model');
1354                                                                                         ltm.loadFile(file);
1355                                                                                         
1356                                                                                         return true;
1357                                                                                 }
1358                                                                             },
1359                                                                             items : [
1360                                                                                 {
1361                                                                                     xtype: Gtk.TreeStore,
1362                                                                                     pack : "set_model",
1363                                                                                     id : "model",
1364                                                                                     init : function() {
1365                                                                                         XObject.prototype.init.call(this);
1366                                                                                       this.el.set_column_types ( 3, [
1367                                                                                                         GObject.TYPE_STRING, // title 
1368                                                                                                         GObject.TYPE_STRING, // tip
1369                                                                                                         GObject.TYPE_STRING // id..
1370                                                                                                         ] );
1371                                                                                        
1372                                                                                     },
1373                                                                                     loadProject : function(pr) {
1374                                                                                     print("LOAD PROJECT");
1375                                                                                                this.el.clear();
1376                                                                                                 if (!pr) {
1377                                                                                                     return;
1378                                                                                                 }
1379                                                                                                 
1380                                                                                                 this.get('/LeftProjectTree').project = pr;
1381                                                                                                 this.load(pr.toTree());
1382                                                                                                 this.get('/LeftProjectTree.view').el.expand_all();
1383                                                                                     },
1384                                                                                     load : function(tr,iter) {
1385                                                                                         console.dump(tr);
1386                                                                                                 console.log('Project tree load: ' + tr.length);
1387                                                                                                 var citer = new Gtk.TreeIter();
1388                                                                                                 //this.insert(citer,iter,0);
1389                                                                                                 
1390                                                                                                 var _this = this;
1391                                                                                                 tr.forEach(function (r) {
1392                                                                                                     if (!iter) {
1393                                                                                                         _this.el.append(citer);   
1394                                                                                                     } else {
1395                                                                                                         _this.el.insert(citer,iter,-1);
1396                                                                                                     }
1397                                                                                                     _this.el.set_value(citer, 0,  '' + r.getTitle() ); // title 
1398                                                                                                     _this.el.set_value(citer, 1, '' + r.getTitleTip()); // tip
1399                                                                                                     _this.el.set_value(citer, 2, '' + r.id ); //id
1400                                                                                                     if (r.cn && r.cn.length) {
1401                                                                                                         _this.load(r.cn, citer);
1402                                                                                                     }
1403                                                                                                     
1404                                                                                                 });
1405                                                                                     },
1406                                                                                     getValue : function(iter, col) {
1407                                                                                         var gval = new GObject.Value('');
1408                                                                                         this.el.get_value(iter, col ,gval);
1409                                                                                         return  '' + gval.value;
1410                                                                                     }
1411                                                                                 },
1412                                                                                 {
1413                                                                                     xtype: Gtk.TreeViewColumn,
1414                                                                                     pack : "append_column",
1415                                                                                     init : function() {
1416                                                                                         XObject.prototype.init.call(this);
1417                                                                                         this.el.add_attribute(this.items[0].el , 'markup', 0 );
1418                                                                                     },
1419                                                                                     items : [
1420                                                                                         {
1421                                                                                             xtype: Gtk.CellRendererText,
1422                                                                                             pack : "pack_start"
1423                                                                                         }
1424                                                                                     ]
1425                                                                                 }
1426                                                                             ]
1427                                                                         }
1428                                                                     ]
1429                                                                 }
1430                                                             ]
1431                                                         }
1432                                                     ]
1433                                                 }
1434                                             ]
1435                                         },
1436                                         {
1437                                             xtype: Gtk.VBox,
1438                                             listeners : {
1439                                                 
1440                                             },
1441                                             items : [
1442                                                 {
1443                                                     xtype: Gtk.HBox,
1444                                                     pack : "pack_start,false,true,0",
1445                                                     id : "LeftProps",
1446                                                     items : [
1447                                                         {
1448                                                             xtype: Gtk.Button,
1449                                                             pack : "add",
1450                                                             listeners : {
1451                                                                 "button_press_event":function (self, event) {
1452                                                                     this.get('/MidPropTree.model').showData('props');
1453                                                                     return false;
1454                                                                 }
1455                                                             },
1456                                                             items : [
1457                                                                 {
1458                                                                     xtype: Gtk.HBox,
1459                                                                     pack : "add",
1460                                                                     items : [
1461                                                                         {
1462                                                                             xtype: Gtk.Image,
1463                                                                             pack : "add",
1464                                                                             stock : Gtk.STOCK_ADD,
1465                                                                             icon_size : Gtk.IconSize.MENU
1466                                                                         },
1467                                                                         {
1468                                                                             xtype: Gtk.Label,
1469                                                                             pack : "add",
1470                                                                             label : "Property"
1471                                                                         }
1472                                                                     ]
1473                                                                 }
1474                                                             ]
1475                                                         },
1476                                                         {
1477                                                             xtype: Gtk.Button,
1478                                                             pack : "add",
1479                                                             listeners : {
1480                                                                 "button_press_event":function (self, event) {
1481                                                                     this.get('/MidPropTree.model').showData('events');
1482                                                                     return false;
1483                                                                 }
1484                                                             },
1485                                                             items : [
1486                                                                 {
1487                                                                     xtype: Gtk.HBox,
1488                                                                     pack : "add",
1489                                                                     items : [
1490                                                                         {
1491                                                                             xtype: Gtk.Image,
1492                                                                             pack : "add",
1493                                                                             stock : Gtk.STOCK_ADD,
1494                                                                             icon_size : Gtk.IconSize.MENU
1495                                                                         },
1496                                                                         {
1497                                                                             xtype: Gtk.Label,
1498                                                                             pack : "add",
1499                                                                             label : "Handler"
1500                                                                         }
1501                                                                     ]
1502                                                                 }
1503                                                             ]
1504                                                         },
1505                                                         {
1506                                                             xtype: Gtk.Button,
1507                                                             pack : "add",
1508                                                             listeners : {
1509                                                                 "button_press_event":function (self, ev) {
1510                                                                         var p = this.get('/AddPropertyPopup');
1511                                                                         if (!p.el) {
1512                                                                                 p.init();
1513                                                                         }
1514                                                                         p.el.set_screen(Gdk.Screen.get_default());
1515                                                                         p.el.show_all();
1516                                                                          p.el.popup(null, null, null, null, 3, ev.button.time);
1517                                                                     return true;
1518                                                                 }
1519                                                             },
1520                                                             items : [
1521                                                                 {
1522                                                                     xtype: Gtk.HBox,
1523                                                                     pack : "add",
1524                                                                     items : [
1525                                                                         {
1526                                                                             xtype: Gtk.Image,
1527                                                                             pack : "add",
1528                                                                             stock : Gtk.STOCK_ADD,
1529                                                                             icon_size : Gtk.IconSize.MENU
1530                                                                         },
1531                                                                         {
1532                                                                             xtype: Gtk.Label,
1533                                                                             pack : "add",
1534                                                                             label : "Other"
1535                                                                         }
1536                                                                     ]
1537                                                                 },
1538                                                                 {
1539                                                                     xtype: Gtk.Menu,
1540                                                                     pack : false,
1541                                                                     id : "AddPropertyPopup",
1542                                                                     items : [
1543                                                                         {
1544                                                                             xtype: Gtk.MenuItem,
1545                                                                             pack : "append",
1546                                                                             tooltip_markup : "Using this.get('*someid') will find any id in an application.",
1547                                                                             label : "ID",
1548                                                                             listeners : {
1549                                                                                 "activate":function (self) {
1550                                                                                 
1551                                                                                     this.get('/LeftPanel.model').add( {
1552                                                                                         key : 'id', 
1553                                                                                         type : 'string',
1554                                                                                         val : '',
1555                                                                                         //skel  : skel,
1556                                                                                         etype : 'props'
1557                                                                                     });
1558                                                                                 }
1559                                                                             }
1560                                                                         },
1561                                                                         {
1562                                                                             xtype: Gtk.MenuItem,
1563                                                                             pack : "append",
1564                                                                             tooltip_markup : "Add what type of packing is to be used",
1565                                                                             label : "PACK",
1566                                                                             listeners : {
1567                                                                                 "activate":function (self) {
1568                                                                                 
1569                                                                                     this.get('/LeftPanel.model').add( {
1570                                                                                          key : 'pack', 
1571                                                                                          type : 'string',
1572                                                                                          val : 'add',
1573                                                                                           etype : 'props'
1574                                                                                     });
1575                                                                                 }
1576                                                                             }
1577                                                                         },
1578                                                                         {
1579                                                                             xtype: Gtk.MenuItem,
1580                                                                             pack : "append",
1581                                                                             tooltip_markup : "Override the init method",
1582                                                                             label : "INIT",
1583                                                                             listeners : {
1584                                                                                 "activate":function (self) {
1585                                                                                 
1586                                                                                     this.get('/LeftPanel.model').add( {
1587                                                                                        key : '|init', 
1588                                                                                         type : 'function',
1589                                                                                         val  : "function() {\n    XObject.prototype.init.call(this);\n}\n",
1590                                                                                         etype : 'props'
1591                                                                                     });
1592                                                                                 }
1593                                                                             }
1594                                                                         },
1595                                                                         {
1596                                                                             xtype: Gtk.SeparatorMenuItem,
1597                                                                             pack : "add"
1598                                                                         },
1599                                                                         {
1600                                                                             xtype: Gtk.MenuItem,
1601                                                                             pack : "append",
1602                                                                             tooltip_markup : "Add a user defined string property",
1603                                                                             label : "String",
1604                                                                             listeners : {
1605                                                                                 "activate":function (self) {
1606                                                                                 
1607                                                                                     this.get('/LeftPanel.model').add( {
1608                                                                                                   key : '', 
1609                                                                                                 type : 'string',
1610                                                                                                 val  : "",
1611                                                                                                 etype : 'props'
1612                                                                                     });
1613                                                                                 }
1614                                                                             }
1615                                                                         },
1616                                                                         {
1617                                                                             xtype: Gtk.MenuItem,
1618                                                                             pack : "append",
1619                                                                             tooltip_markup : "Add a user defined number property",
1620                                                                             label : "Number",
1621                                                                             listeners : {
1622                                                                                 "activate":function (self) {
1623                                                                                 
1624                                                                                     this.get('/LeftPanel.model').add( {
1625                                                                                                   key : '', 
1626                                                                                                 type : 'number',
1627                                                                                                 val  : 0,
1628                                                                                                 etype : 'props'
1629                                                                                     });
1630                                                                                 }
1631                                                                             }
1632                                                                         },
1633                                                                         {
1634                                                                             xtype: Gtk.MenuItem,
1635                                                                             pack : "append",
1636                                                                             tooltip_markup : "Add a user defined boolean property",
1637                                                                             label : "Boolean",
1638                                                                             listeners : {
1639                                                                                 "activate":function (self) {
1640                                                                                 
1641                                                                                     this.get('/LeftPanel.model').add( {
1642                                                                                                   key : '', 
1643                                                                                                 type : 'boolean',
1644                                                                                                 val  : false,
1645                                                                                                 etype : 'props'
1646                                                                                     });
1647                                                                                 }
1648                                                                             }
1649                                                                         },
1650                                                                         {
1651                                                                             xtype: Gtk.SeparatorMenuItem,
1652                                                                             pack : "add"
1653                                                                         },
1654                                                                         {
1655                                                                             xtype: Gtk.MenuItem,
1656                                                                             pack : "append",
1657                                                                             tooltip_markup : "Add a user function boolean property",
1658                                                                             label : "Function",
1659                                                                             listeners : {
1660                                                                                 "activate":function (self) {
1661                                                                                 
1662                                                                                     this.get('/LeftPanel.model').add( {
1663                                                                                             key : '|', 
1664                                                                                                         type : 'function',
1665                                                                                                         val  : "function() {\n    \n}\n",
1666                                                                                                         etype : 'props'
1667                                                                                     });
1668                                                                                 }
1669                                                                             }
1670                                                                         }
1671                                                                     ]
1672                                                                 }
1673                                                             ]
1674                                                         }
1675                                                     ]
1676                                                 },
1677                                                 {
1678                                                     xtype: Gtk.ScrolledWindow,
1679                                                     id : "LeftPanel",
1680                                                     pack : "add",
1681                                                     shadow_type : Gtk.ShadowType.IN,
1682                                                     editing : false,
1683                                                     init : function() {
1684                                                         XObject.prototype.init.call(this);
1685                                                        this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1686                                                     },
1687                                                     items : [
1688                                                         {
1689                                                             xtype: Gtk.TreeView,
1690                                                             id : "view",
1691                                                             tooltip_column : 1,
1692                                                             headers_visible : false,
1693                                                             enable_tree_lines : true,
1694                                                             init : function() {
1695                                                                  XObject.prototype.init.call(this); 
1696                                                                                    
1697                                                                                 this.selection = this.el.get_selection();
1698                                                                                 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1699                                                                              
1700                                                                                 
1701                                                                                 var description = new Pango.FontDescription.c_new();
1702                                                                                 description.set_size(8000);
1703                                                                                 this.el.modify_font(description);
1704                                                             },
1705                                                             listeners : {
1706                                                                 "button_press_event":function (self, ev) {
1707                                                                     
1708                                                                                 
1709                                                                                 var res = { }; 
1710                                                                                 if (!this.el.get_path_at_pos(ev.button.x,ev.button.y, res)) {
1711                                                                                     return false; //not on a element.
1712                                                                                 }
1713                                                                                 
1714                                                                                 
1715                                                                                 if (ev.type != Gdk.EventType.BUTTON_PRESS  || ev.button.button != 3) {
1716                                                                                     
1717                                                                                     if (res.column.title != 'value') {
1718                                                                                         return false; // ignore..
1719                                                                                     }
1720                                                                                     if (  this.get('/LeftPanel').editing) {
1721                                                                                         return false;
1722                                                                                     }
1723                                                                                     var renderer = this.get('/LeftPanel').editableColumn.items[0].el; // set has_entry..
1724                                                                                     this.get('/LeftPanel').editableColumn.items[0].el.stop_editing();
1725                                                                                     var type = this.get('/LeftPanel.model').getType(res.path.to_string());
1726                                                                                     
1727                                                                                      
1728                                                                 
1729                                                                                     var provider = this.get('/LeftTree').getPaleteProvider();
1730                                                                                     
1731                                                                                     var opts = provider.findOptions(type);
1732                                                                                     
1733                                                                                     if (opts === false) {
1734                                                                                          this.get('/LeftPanel').editableColumn.setOptions([]);
1735                                                                                         renderer.has_entry = true;
1736                                                                                     } else {
1737                                                                                         LeftPanel.editableColumn.setOptions(opts);
1738                                                                                         renderer.has_entry = false;
1739                                                                                     }
1740                                                                                     
1741                                                                                     
1742                                                                                    //Seed.print("click" + ev.type);
1743                                                                                     //console.dump(res);
1744                                                                                     return false;
1745                                                                                 }
1746                                                                               
1747                                                                             
1748                                                                                
1749                                                                                 if (res.column.title == 'value') {
1750                                                                                     return false;
1751                                                                                 }
1752                                                                                 //if (! this.get('/LeftPanelPopup')LeftPanelPopup.el) LeftPanelPopup.init();
1753                                                                                 var p = this.get('/LeftPanelPopup');
1754                                                                                 if (!p.el) {
1755                                                                                         p.init();
1756                                                                                 }
1757                                                                 
1758                                                                                 p.el.set_screen(Gdk.Screen.get_default());
1759                                                                                 p.el.show_all();
1760                                                                                 p.el.popup(null, null, null, null, 3, ev.button.time);
1761                                                                                 //Seed.print("click:" + res.column.title);
1762                                                                                 
1763                                                                                 
1764                                                                                 return false;
1765                                                                 }
1766                                                             },
1767                                                             items : [
1768                                                                 {
1769                                                                     xtype: Gtk.TreeStore,
1770                                                                     pack : "set_model",
1771                                                                     id : "model",
1772                                                                     init : function() {
1773                                                                         XObject.prototype.init.call(this);
1774                                                                     this.el.set_column_types ( 5, [
1775                                                                                                     GObject.TYPE_STRING,  // 0 real key
1776                                                                                                     GObject.TYPE_STRING, // 1 real value 
1777                                                                                                      GObject.TYPE_STRING,  // 2 visable key
1778                                                                                                      GObject.TYPE_STRING, // 3 visable value
1779                                                                                                      GObject.TYPE_STRING, // 4 need to store type of!!!
1780                                                                                                   
1781                                                                                                 ]);
1782                                                                     },
1783                                                                     toShort : function(str) {
1784                                                                         var a = typeof(str) == 'string' ? str.split("\n") : [];
1785                                                                             return a.length > 1 ? a[0] + '....' : '' + str;
1786                                                                     },
1787                                                                     load : function(ar) {
1788                                                                          this.el.clear();
1789                                                                                                 
1790                                                                                 this.get('/RightEditor').el.hide();
1791                                                                                 if (ar === false) {
1792                                                                                     return ;
1793                                                                                 }
1794                                                                                 var ret = {}; 
1795                                                                                 
1796                                                                     
1797                                                                                 var provider = this.get('/LeftTree').getPaleteProvider();
1798                                                                                 
1799                                                                                 // sort!!!?
1800                                                                                 var iter = new Gtk.TreeIter();
1801                                                                                 for (var i in ar) {
1802                                                                                     if (typeof(ar[i]) == 'object') {
1803                                                                                         continue;
1804                                                                                     }
1805                                                                                     
1806                                                                                     var type = provider.findType(ar, i, ar[i]);
1807                                                                                     
1808                                                                                     this.el.append(iter);
1809                                                                                     var p = this.el.get_path(iter).to_string();
1810                                                                                     ret[i] = p;
1811                                                                                     this.el.set_value(iter, 0, i);
1812                                                                                     this.el.set_value(iter, 1, '' + ar[i]);
1813                                                                                     this.el.set_value(iter, 2, i);
1814                                                                                     this.el.set_value(iter, 3, this.toShort(ar[i]));
1815                                                                                     this.el.set_value(iter, 4, type);
1816                                                                                 }
1817                                                                                 ar.listeners = ar.listeners || {};
1818                                                                                 for (var i in ar.listeners ) {
1819                                                                                     this.el.append(iter);
1820                                                                                     var p = this.el.get_path(iter).to_string();
1821                                                                                     ret['!' + i] = p;
1822                                                                                     
1823                                                                                     this.el.set_value(iter, 0, '!'+  i  );
1824                                                                                     this.el.set_value(iter, 1, '' + ar.listeners[i]);
1825                                                                                     this.el.set_value(iter, 2, '<b>'+ i + '</b>');
1826                                                                                     
1827                                                                                     this.el.set_value(iter, 3, '' + this.toShort(ar.listeners[i]));
1828                                                                                     this.el.set_value(iter, 4, 'function');
1829                                                                                 }
1830                                                                                 return ret;
1831                                                                     },
1832                                                                     add : function(info) {
1833                                                                           // info includes key, val, skel, etype..
1834                                                                                                  console.dump(info);
1835                                                                                 type = info.type.toLowerCase();
1836                                                                                 var data = this.toJS();
1837                                                                                 
1838                                                                                 if (info.etype == 'events') {
1839                                                                                     data.listeners = data.listeners || { };
1840                                                                                     if (typeof(data.listeners[info.key]) != 'undefined') {
1841                                                                                         return; //already set!
1842                                                                                     }
1843                                                                                 } else {
1844                                                                                     if (typeof(data[info.key]) != 'undefined') {
1845                                                                                         return;
1846                                                                                     }
1847                                                                                 }
1848                                                                                 
1849                                                                                 if (typeof(info.val) == 'undefined') {
1850                                                                                         
1851                                                                                     info.val = '';
1852                                                                                     if (info.type == 'boolean') {
1853                                                                                         info.val = true;
1854                                                                                     }
1855                                                                                     if (type == 'number') {
1856                                                                                         info.val = 0;
1857                                                                                     }
1858                                                                                     // utf8 == string..
1859                                                                                     
1860                                                                                     
1861                                                                                 }
1862                                                                                 var k = info.key;
1863                                                                                 if (info.etype == 'events') {
1864                                                                                  
1865                                                                                     data.listeners[info.key] = info.val;
1866                                                                                     k = '!' + info.key;
1867                                                                                 } else {
1868                                                                                     data[info.key] = info.val;
1869                                                                                 }
1870                                                                                 
1871                                                                                 
1872                                                                                 var map = this.load(data);
1873                                                                                 
1874                                                                                 // flag it as changed to the interface..
1875                                                                     
1876                                                                                 this.get('/LeftTree.model').changed(data, true); 
1877                                                                                 
1878                                                                                 
1879                                                                                 this.startEditing(map[k]);
1880                                                                                  
1881                                                                                 /*
1882                                                                                 LeftPanel.get('view').el.row_activated(
1883                                                                                     new Gtk.TreePath.from_string(map[k]), 
1884                                                                                     LeftPanel.editableColumn.el
1885                                                                                 );
1886                                                                                 */
1887                                                                     },
1888                                                                     startEditing : function(path,col) {
1889                                                                     /**
1890                                                                     * start editing path (or selected if not set..)
1891                                                                     * @param {String|false} path  (optional) treepath to edit - selected tree gets
1892                                                                     *     edited by default.
1893                                                                     * @param {Number} 0 or 1 (optional)- column to edit. 
1894                                                                     */
1895                                                                          var tp;
1896                                                                                 if (typeof(path) == 'string') {
1897                                                                                     tp = new Gtk.TreePath.from_string(path);
1898                                                                                 } else {
1899                                                                                     var iter = new Gtk.TreeIter();
1900                                                                                     var s = this.get('/LeftPanel.view').selection;
1901                                                                                     s.get_selected(this.el, iter);
1902                                                                                     tp = this.el.get_path(iter);
1903                                                                                     path = tp.to_string();
1904                                                                                 }
1905                                                                                 
1906                                                                                
1907                                                                                 // which colum is to be edited..
1908                                                                                 var colObj = false;
1909                                                                                 if (typeof(col) == 'undefined') {
1910                                                                                     var k = this.getValue(path, 0);
1911                                                                                     colObj = (!k.length || k == '|') ? 
1912                                                                                         this.get('/LeftPanel').propertyColumn : this.get('/LeftPanel').editableColumn;
1913                                                                                 } else {
1914                                                                                     colObj = col ? this.get('/LeftPanel').editableColumn : this.get('/LeftPanel').propertyColumn;
1915                                                                                 }
1916                                                                                 
1917                                                                                 // make sure the pulldown is set correctly..
1918                                                                                 // not really needed for second col...
1919                                                                     
1920                                                                                 var provider = this.get('/LeftTree').getPaleteProvider();
1921                                                                                
1922                                                                                 var type = this.get('/LeftPanel.model').getType(path);
1923                                                                                 var opts = provider.findOptions(type);
1924                                                                                 var renderer = this.get('/LeftPanel').editableColumn.items[0].el;
1925                                                                                 
1926                                                                                 if (opts === false) {
1927                                                                                     this.get('/LeftPanel').editableColumn.setOptions([]);
1928                                                                                     renderer.has_entry = true; /// probably does not have any effect.
1929                                                                                 } else {
1930                                                                                     this.get('/LeftPanel').editableColumn.setOptions(opts);
1931                                                                                     renderer.has_entry = false;
1932                                                                                 }
1933                                                                                 
1934                                                                                 var _this=this;
1935                                                                                 // iter now has row...
1936                                                                                 GLib.timeout_add(0, 100, function() {
1937                                                                                     
1938                                                                                     colObj.items[0].el.editable = true; // esp. need for col 0..
1939                                                                                     _this.get('/LeftPanel.view').el.set_cursor_on_cell(
1940                                                                                         tp,
1941                                                                                         colObj.el,
1942                                                                                         colObj.items[0].el,
1943                                                                                         true
1944                                                                                     );
1945                                                                                 });
1946                                                                                 
1947                                                                     },
1948                                                                     deleteSelected : function() {
1949                                                                          var data = this.toJS();
1950                                                                         var iter = new Gtk.TreeIter();
1951                                                                         var s = this.get('/LeftPanel.view').selection;
1952                                                                         s.get_selected(this.el, iter);
1953                                                                              
1954                                                                            
1955                                                                         var gval = new GObject.Value('');
1956                                                                        this.get('/LeftPanel.model').el.get_value(iter, 0 ,gval);
1957                                                                         
1958                                                                         var val = gval.value;
1959                                                                         if (val[0] == '!') {
1960                                                                             // listener..
1961                                                                             if (!data.listeners || typeof(data.listeners[  val.substring(1)]) == 'undefined') {
1962                                                                                 return;
1963                                                                             }
1964                                                                             delete data.listeners[  val.substring(1)];
1965                                                                             if (!XObject.keys(data.listeners).length) {
1966                                                                                 delete data.listeners;
1967                                                                             }
1968                                                                             
1969                                                                         } else {
1970                                                                             if (typeof(data[val]) == 'undefined') {
1971                                                                                 return;
1972                                                                             }
1973                                                                             delete data[val];
1974                                                                         }
1975                                                                         
1976                                                                         
1977                                                                         this.load(data);
1978                                                                         this.get('/LeftTree.model').changed(data, true);
1979                                                                         
1980                                                                     },
1981                                                                     activePath : false,
1982                                                                     changed : function(str, doRefresh) {
1983                                                                         if (!this.activePath) {
1984                                                                             return;
1985                                                                         }
1986                                                                         var iter = new Gtk.TreeIter();
1987                                                                         this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath));
1988                                                                         
1989                                                                         this.el.set_value(iter, 1, '' +str);
1990                                                                         this.el.set_value(iter, 3, '' + this.toShort(str));
1991                                                                         // update the tree...  
1992                                                                     
1993                                                                         this.get('/LeftTree.model').changed(this.toJS(), doRefresh); 
1994                                                                     },
1995                                                                     toJS : function() {
1996                                                                          var iter = new Gtk.TreeIter();
1997                                                                         this.get('/LeftPanel.model').el.get_iter_first(iter);
1998                                                                         var ar = {};
1999                                                                            
2000                                                                         while (true) {
2001                                                                             
2002                                                                             var k = this.getValue(this.el.get_path(iter).to_string(), 0);
2003                                                                            // Seed.print(k);
2004                                                                             if (k[0] == '!') {
2005                                                                                 ar.listeners = ar.listeners || {};
2006                                                                                 ar.listeners[  k.substring(1)] = this.getValue(this.el.get_path(iter).to_string(), 1);
2007                                                                                 
2008                                                                             } else {
2009                                                                                 ar[ k ] = this.getValue(this.el.get_path(iter).to_string(), 1);
2010                                                                             }
2011                                                                             
2012                                                                             if (! this.get('/LeftPanel.model').el.iter_next(iter)) {
2013                                                                                 break;
2014                                                                             }
2015                                                                         }
2016                                                                         
2017                                                                         
2018                                                                         //print(JSON.stringify(ar));
2019                                                                         return ar;
2020                                                                         // convert the l
2021                                                                     },
2022                                                                     getType : function(treepath) {
2023                                                                          return this.getValue(treepath, 4);
2024                                                                     },
2025                                                                     getValue : function(treepath_str, col) {
2026                                                                           var iter = new Gtk.TreeIter();
2027                                                                         this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath_str));
2028                                                                         
2029                                                                         var gval = new GObject.Value('');
2030                                                                         this.get('/LeftPanel.model').el.get_value(iter, col ,gval);
2031                                                                         var val = '' + gval.value;
2032                                                                         if (col != 1) {
2033                                                                             return val;
2034                                                                         }
2035                                                                         var type = this.getType(this.el.get_path(iter).to_string());
2036                                                                         //print("TYPE: " +type + " -  val:" + val);
2037                                                                         switch(type.toLowerCase()) {
2038                                                                             case 'number':
2039                                                                             case 'uint':
2040                                                                             case 'int':
2041                                                                                 return parseFloat(val); // Nan ?? invalid!!?
2042                                                                             case 'boolean':
2043                                                                                 return val == 'true' ? true : false;
2044                                                                             default: 
2045                                                                                 return val;
2046                                                                         }
2047                                                                                                 
2048                                                                     },
2049                                                                     editSelected : function(e) {
2050                                                                         print("EDIT SELECTED?");
2051                                                                         var iter = new Gtk.TreeIter();
2052                                                                         var s = this.get('/LeftPanel.view').selection;
2053                                                                         s.get_selected(this.get('/LeftPanel.model').el, iter);
2054                                                                         var m = this.get('/LeftPanel.model')
2055                                                                        
2056                                                                         var gval = new GObject.Value('');
2057                                                                         this.el.get_value(iter, 0 ,gval);
2058                                                                         var val = '' + gval.value;
2059                                                                         
2060                                                                         gval = new GObject.Value('');
2061                                                                         this.el.get_value(iter, 1 ,gval);
2062                                                                         var rval = gval.value;
2063                                                                         var activePath = this.el.get_path(iter).to_string(); 
2064                                                                         this.activePath = activePath ;
2065                                                                         // was activeIter...
2066                                                                         //  not listener...
2067                                                                     
2068                                                                         var showEditor = false;
2069                                                                         
2070                                                                         if (val[0] == '!') {
2071                                                                             showEditor = true;
2072                                                                         }
2073                                                                         if (val[0] == '|') {
2074                                                                             if (rval.match(/function/g) || rval.match(/\n/g)) {
2075                                                                                 showEditor = true;
2076                                                                             }
2077                                                                         }
2078                                                                         
2079                                                                         if (showEditor) {
2080                                                                             var _this = this;
2081                                                                             this.activePath = false;
2082                                                                             GLib.timeout_add(0, 1, function() {
2083                                                                                 //   Gdk.threads_enter();
2084                                                                                 _this.get('/BottomPane').el.show();
2085                                                                                 _this.get('/RightEditor').el.show();
2086                                                                        _this.get('/RightEditor.view').load( rval );
2087                                                                                 
2088                                                                                 e.editing_done();
2089                                                                                 e.remove_widget();
2090                                                                                 _this.activePath = activePath ;
2091                                                                                 
2092                                                                          //       Gdk.threads_leave();
2093                                                                                 return false;
2094                                                                             });
2095                                                                             return;
2096                                                                         }
2097                                                                           this.get('/BottomPane').el.hide();
2098                                                                         this.get('/RightEditor').el.hide();
2099                                                                     
2100                                                                             //var type = this.getValue(this.el.get_path(iter).to_string(),4);
2101                                                                             
2102                                                                             
2103                                                                     }
2104                                                                 },
2105                                                                 {
2106                                                                     xtype: Gtk.TreeViewColumn,
2107                                                                     pack : "append_column",
2108                                                                     init : function() {
2109                                                                         XObject.prototype.init.call(this);
2110                                                                     
2111                                                                         this.el.add_attribute(this.items[0].el , 'markup', 2 );
2112                                                                         this.get('/LeftPanel').propertyColumn = this;
2113                                                                     },
2114                                                                     title : "key",
2115                                                                     items : [
2116                                                                         {
2117                                                                             xtype: Gtk.CellRendererText,
2118                                                                             pack : "pack_start",
2119                                                                             listeners : {
2120                                                                                 "editing_started":function (self, editable, path) {
2121                                                                                 
2122                                                                                         this.get('/LeftPanel.model').activePath  = path;
2123                                                                                 
2124                                                                                 },
2125                                                                                 "edited":function (self, object, p0) {
2126                                                                                         var model = this.get('/LeftPanel.model');
2127                                                                                         var path = model.activePath;
2128                                                                                         var iter = new Gtk.TreeIter();
2129                                                                                         model.el.get_iter(iter, new Gtk.TreePath.from_string(path));
2130                                                                                         model.el.set_value(iter, 0, p0);
2131                                                                                         model.el.set_value(iter, 2, p0);
2132                                                                                         
2133                                                                                         model.activePath = false;
2134                                                                                 
2135                                                                                         this.get('/LeftTree.model').changed(model.toJS(), true); 
2136                                                                                         this.el.editable = false;
2137                                                                                 }
2138                                                                             }
2139                                                                         }
2140                                                                     ]
2141                                                                 },
2142                                                                 {
2143                                                                     xtype: Gtk.TreeViewColumn,
2144                                                                     pack : "append_column",
2145                                                                     init : function() {
2146                                                                         XObject.prototype.init.call(this);
2147                                                                         this.el.add_attribute(this.items[0].el , 'text', 3 );
2148                                                                         this.el.add_attribute(this.items[0].el , 'sensitive', 3 );
2149                                                                         this.el.add_attribute(this.items[0].el , 'editable', 3 );
2150                                                                               // this.el.set_cell_data_func(cell, age_cell_data_func, NULL, NULL);
2151                                                                     
2152                                                                         this.get('/LeftPanel').editableColumn= this;
2153                                                                     },
2154                                                                     setOptions : function(ar) {
2155                                                                            var m = this.items[0].el.model;
2156                                                                                 m.clear();
2157                                                                                 var iter = new Gtk.TreeIter();
2158                                                                                 ar.forEach(function(i) {
2159                                                                                        // sort!!!?
2160                                                                                     m.append(iter);
2161                                                                                     m.set_value(iter, 0, i);
2162                                                                                 });
2163                                                                                 
2164                                                                     },
2165                                                                     items : [
2166                                                                         {
2167                                                                             xtype: Gtk.CellRendererCombo,
2168                                                                             pack : "pack_start",
2169                                                                             editable : true,
2170                                                                             has_entry : true,
2171                                                                             text_column : 0,
2172                                                                             init : function() {
2173                                                                                 XObject.prototype.init.call(this);
2174                                                                                this.el.model = new Gtk.ListStore();
2175                                                                                 this.el.model.set_column_types ( 1, [
2176                                                                                     GObject.TYPE_STRING  // 0 real key
2177                                                                                   ]);
2178                                                                             },
2179                                                                             listeners : {
2180                                                                                 "edited":function (self, object, p0) {
2181                                                                                         this.get('/LeftPanel').editing = false;
2182                                                                                         print("EDITED? p:" + p0 + " t:" + p0);
2183                                                                                         this.get('/LeftPanel.model').changed(p0, true);
2184                                                                                         this.get('/LeftPanel.model').activePath = false;
2185                                                                                 },
2186                                                                                 "editing_started":function (self, editable, path) {
2187                                                                                    this.get('/LeftPanel').editing  = true;
2188                                                                                         //  console.log('editing started');
2189                                                                                        // r.has_entry = false;
2190                                                                                    this.get('/LeftPanel.model').editSelected(editable);
2191                                                                                 }
2192                                                                             }
2193                                                                         }
2194                                                                     ]
2195                                                                 }
2196                                                             ]
2197                                                         },
2198                                                         {
2199                                                             xtype: Gtk.Menu,
2200                                                             pack : false,
2201                                                             id : "LeftPanelPopup",
2202                                                             items : [
2203                                                                 {
2204                                                                     xtype: Gtk.MenuItem,
2205                                                                     pack : "append",
2206                                                                     label : "Delete",
2207                                                                     listeners : {
2208                                                                         "activate":function (self) {
2209                                                                                 this.get('/LeftPanel.model').deleteSelected();
2210                                                                         }
2211                                                                     }
2212                                                                 },
2213                                                                 {
2214                                                                     xtype: Gtk.MenuItem,
2215                                                                     pack : "append",
2216                                                                     label : "Edit",
2217                                                                     listeners : {
2218                                                                         "activate":function (self) {
2219                                                                                 this.get('/LeftPanel.model').startEditing(false, 0);
2220                                                                         }
2221                                                                     }
2222                                                                 }
2223                                                             ]
2224                                                         }
2225                                                     ]
2226                                                 }
2227                                             ]
2228                                         }
2229                                     ]
2230                                 },
2231                                 {
2232                                     xtype: Gtk.ScrolledWindow,
2233                                     pack : "pack_end,false,true,0",
2234                                     id : "MidPropTree",
2235                                     shadow_type : Gtk.ShadowType.IN,
2236                                     init : function() {
2237                                         XObject.prototype.init.call(this);
2238                                            XObject.prototype.init.call(this); 
2239                                         this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
2240                                         this.el.set_size_request ( 150, -1 );
2241                                         this.shown = true;
2242                                     },
2243                                     activeElement : false,
2244                                     hideWin : function() {
2245                                          
2246                                         if (!this.shown) {
2247                                             return;
2248                                         }
2249                                         
2250                                         
2251                                         if (this.get('/Window.left').el.position < 160) {
2252                                             return;
2253                                         }
2254                                         this.get('/Window.left').el.position = this.get('/Window.left').el.position  - 150;
2255                                             
2256                                         this.el.hide();
2257                                         this.shown = false;
2258                                     },
2259                                     items : [
2260                                         {
2261                                             xtype: Gtk.TreeView,
2262                                             enable_tree_lines : true,
2263                                             headers_visible : false,
2264                                             tooltip_column : 2,
2265                                             init : function() {
2266                                                 XObject.prototype.init.call(this); 
2267                                                                 
2268                                                    var description = new Pango.FontDescription.c_new();
2269                                                  description.set_size(8000);
2270                                                 this.el.modify_font(description);     
2271                                                                 
2272                                                 //this.selection = this.el.get_selection();
2273                                                 // this.selection.set_mode( Gtk.SelectionMode.SINGLE);
2274                                              
2275                                             
2276                                                 
2277                                               
2278                                                 
2279                                             },
2280                                             pack : "add",
2281                                             listeners : {
2282                                                 "cursor_changed":function (self) {
2283                                                        var iter = new Gtk.TreeIter();
2284                                                                         
2285                                                                         //console.log('changed');
2286                                                         var m = this.get('model');
2287                                                         if (!this.selection){
2288                                                                 this.selection = this.el.get_selection();
2289                                                         }
2290                                                 
2291                                                         var s = this.selection;
2292                                                         if (!s.get_selected(m.el, iter)) {
2293                                                                 return; 
2294                                                         }
2295                                                         var tp = m.el.get_path(iter).to_string();
2296                                                         
2297                                                         
2298                                                         // var val = "";
2299                                                         
2300                                                         var key = m.getValue(tp, 0);
2301                                                         
2302                                                         var type = m.getValue(tp, 1);
2303                                                         var skel = m.getValue(tp, 3);
2304                                                         var etype = m.getValue(tp, 5);
2305                                                         
2306                                                         
2307                                                         this.get('/MidPropTree').hideWin();
2308                                                 
2309                                                         if (type == 'function') {
2310                                                             
2311                                                             if (etype != 'events') {
2312                                                                 key = '|' + key;
2313                                                             }
2314                                                             
2315                                                             this.get('/LeftPanel.model').add({
2316                                                                 key :  key, 
2317                                                                 type : type,
2318                                                                 val  : skel,
2319                                                                 etype : etype
2320                                                             })  
2321                                                             return;
2322                                                         }
2323                                                         
2324                                                         if (type.indexOf('.') > -1 || 
2325                                                                 type == 'boolean') {
2326                                                              key = '|' + key;
2327                                                         }
2328                                                         
2329                                                         this.get('/LeftPanel.model').add( {
2330                                                             key : key, 
2331                                                             type : type,
2332                                                             //skel  : skel,
2333                                                             etype : etype
2334                                                            }) //, 
2335                                                 }
2336                                             },
2337                                             items : [
2338                                                 {
2339                                                     xtype: Gtk.ListStore,
2340                                                     pack : "set_model",
2341                                                     init : function() {
2342                                                         XObject.prototype.init.call(this);
2343                                                        this.el.set_column_types ( 6, [
2344                                                             GObject.TYPE_STRING,  // real key
2345                                                              GObject.TYPE_STRING, // real type
2346                                                              GObject.TYPE_STRING, // docs ?
2347                                                              GObject.TYPE_STRING, // visable desc
2348                                                              GObject.TYPE_STRING, // function desc
2349                                                              GObject.TYPE_STRING // element type (event|prop)
2350                                                             
2351                                                         ] );
2352                                                     },
2353                                                     getValue : function(treepath, col)
2354                                                     {
2355                                                         var tp = new Gtk.TreePath.from_string (treepath);
2356                                                         var iter = new Gtk.TreeIter();
2357                                                         this.el.get_iter (iter, tp);
2358                                                         var value = new GObject.Value('');
2359                                                         this.el.get_value(iter, col, value);
2360                                                         return value.value;
2361                                                         
2362                                                     },
2363                                                     showData : function(type) {
2364                                                         this.el.clear();
2365                                                                 if (!this.get('/MidPropTree').activeElement || !type) {
2366                                                                     return; // no active element
2367                                                                 }
2368                                                     
2369                                                                 var fullpath = this.get('/LeftTree.model').file.guessName(this.get('/MidPropTree').activeElement);
2370                                                                 var palete = this.get('/LeftTree').getPaleteProvider();
2371                                                                 
2372                                                                  
2373                                                                 
2374                                                                 Seed.print('Showing right?');
2375                                                                 if (!this.get('/MidPropTree').shown) {
2376                                                     
2377                                                                     this.get('/Window.left').el.position = this.get('/Window.left').el.position  + 150;
2378                                                                     this.get('/MidPropTree').el.show();
2379                                                                     this.get('/MidPropTree').shown = true;
2380                                                                 }
2381                                                                 
2382                                                                 var elementList = palete.getPropertiesFor(fullpath, type);
2383                                                                 print ("GOT " + elementList.length + " items for " + fullpath + "|" + type);
2384                                                                // console.dump(elementList);
2385                                                                
2386                                                                 
2387                                                                 var iter = new Gtk.TreeIter();
2388                                                                 for(var i =0 ; i < elementList.length; i++) {
2389                                                                     var p=elementList[i];
2390                                                                     this.el.append(iter);
2391                                                                   //  console.log( '<b>' + p.name +'</b> ['+p.type+']');
2392                                                                         //GObject.TYPE_STRING,  // real key
2393                                                                         // GObject.TYPE_STRING, // real type
2394                                                                         // GObject.TYPE_STRING, // docs ?
2395                                                                         // GObject.TYPE_STRING // func def?
2396                                                                         
2397                                                                     
2398                                                                     this.el.set_value(iter, 0, p.name);
2399                                                                     this.el.set_value(iter, 1, p.type);
2400                                                                     this.el.set_value(iter, 2, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>' + "\n" + p.desc);
2401                                                                     this.el.set_value(iter, 3, p.sig ? p.sig  : '');
2402                                                                     this.el.set_value(iter, 4, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>');
2403                                                                     this.el.set_value(iter, 5, type);
2404                                                                     
2405                                                                 }
2406                                                                                  
2407                                                     },
2408                                                     id : "model"
2409                                                 },
2410                                                 {
2411                                                     xtype: Gtk.TreeViewColumn,
2412                                                     init : function() {
2413                                                         this.el = new Gtk.TreeViewColumn();
2414                                                         this.parent.el.append_column(this.el);
2415                                                         
2416                                                         XObject.prototype.init.call(this);
2417                                                         this.el.add_attribute(this.items[0].el , 'markup', 4  );
2418                                                     },
2419                                                     pack : false,
2420                                                     items : [
2421                                                         {
2422                                                             xtype: Gtk.CellRendererText,
2423                                                             pack : "pack_start,true"
2424                                                         }
2425                                                     ]
2426                                                 }
2427                                             ]
2428                                         }
2429                                     ]
2430                                 }
2431                             ]
2432                         },
2433                         {
2434                             xtype: Gtk.HBox,
2435                             pack : "add",
2436                             items : [
2437                                 {
2438                                     xtype: Gtk.VPaned,
2439                                     pack : "add",
2440                                     position : 300,
2441                                     items : [
2442                                         {
2443                                             xtype: Gtk.VBox,
2444                                             pack : "add",
2445                                             items : [
2446                                                 {
2447                                                     xtype: Gtk.Notebook,
2448                                                     pack : "pack_start,true,true",
2449                                                     id : "view-help-nb",
2450                                                     init : function() {
2451                                                         XObject.prototype.init.call(this);
2452                                                        this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Preview" }));
2453                                                         this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Help" }));
2454                                                     },
2455                                                     items : [
2456                                                         {
2457                                                             xtype: Gtk.Notebook,
2458                                                             pack : "add",
2459                                                             id : "view-notebook",
2460                                                             tab_border : 0,
2461                                                             init : function() {
2462                                                                 XObject.prototype.init.call(this);
2463                                                                 this.el.set_current_page(0);
2464                                                                 print("SET LABEL?")
2465                                                                 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Roo View" }));
2466                                                                 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Gtk View" }));
2467                                                             },
2468                                                             show_tabs : false,
2469                                                             items : [
2470                                                                 {
2471                                                                     xtype: Gtk.VBox,
2472                                                                     pack : "add",
2473                                                                     id : "RightBrowser",
2474                                                                     items : [
2475                                                                         {
2476                                                                             xtype: Gtk.HBox,
2477                                                                             pack : "pack_start,false,true,0",
2478                                                                             items : [
2479                                                                                 {
2480                                                                                     xtype: Gtk.Button,
2481                                                                                     pack : "pack_start,false,false,0",
2482                                                                                     label : "Dump HTML to console",
2483                                                                                     listeners : {
2484                                                                                         "activate":function (self) {
2485                                                                                                 this.get('/RightBrowser.view').el.execute_script(
2486                                                                                                     "console.log(document.body.innerHTML);");
2487                                                                                                 this.get('/RightBrowser.view').el.execute_script(
2488                                                                                                     "console.log(Builder.dump(Builder));");   
2489                                                                                         }
2490                                                                                     }
2491                                                                                 }
2492                                                                             ]
2493                                                                         },
2494                                                                         {
2495                                                                             xtype: Gtk.ScrolledWindow,
2496                                                                             pack : "add",
2497                                                                             shadow_type : Gtk.ShadowType.IN,
2498                                                                             init : function() {
2499                                                                                 XObject.prototype.init.call(this);
2500                                                                               this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
2501                                                                             },
2502                                                                             items : [
2503                                                                                 {
2504                                                                                     xtype: WebKit.WebView,
2505                                                                                     pack : "add",
2506                                                                                     id : "view",
2507                                                                                     init : function() {
2508                                                                                         XObject.prototype.init.call(this);
2509                                                                                         // this may not work!?
2510                                                                                         this.el.open('file:///' + __script_path__ + '/../builder.html');
2511                                                                                                                 
2512                                                                                         Gtk.drag_dest_set
2513                                                                                         (
2514                                                                                                 this.el,              /* widget that will accept a drop */
2515                                                                                                 Gtk.DestDefaults.MOTION  | Gtk.DestDefaults.HIGHLIGHT,
2516                                                                                                 null,            /* lists of target to support */
2517                                                                                                 0,              /* size of list */
2518                                                                                                 Gdk.DragAction.COPY         /* what to do with data after dropped */
2519                                                                                         );
2520                                                                                                                 
2521                                                                                        // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
2522                                                                                         Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
2523                                                                                     },
2524                                                                                     renderJS : function(data) {
2525                                                                                         this.renderedData = data;
2526                                                                                         var str = JSON.stringify(data) ;
2527                                                                                         
2528                                                                                         if (!this.ready) {
2529                                                                                             console.log('not loaded yet');
2530                                                                                         }
2531                                                                                         Seed.print("RENDER:" + str);
2532                                                                                         imports.File.File.write('/tmp/builder.debug.js', "Builder.render(" + JSON.stringify(data) + ");");
2533                                                                                         this.el.execute_script("Builder.render(" + JSON.stringify(data) + ");");
2534                                                                                     },
2535                                                                                     listeners : {
2536                                                                                         "load_finished":function (self, object) {
2537                                                                                                  if (this.ready) { // dont do it twice!
2538                                                                                                     return; 
2539                                                                                                 }
2540                                                                                                 this.ready = true;
2541                                                                                         
2542                                                                                                 this.renderJS(this.get('/LeftTree.model').toJS()[0]);
2543                                                                                         },
2544                                                                                         "script_alert":function (self, object, p0) {
2545                                                                                                 print(p0);
2546                                                                                                 return false;
2547                                                                                                 return true; // do not display anything...
2548                                                                                         },
2549                                                                                         "console_message":function (self, object, p0, p1) {
2550                                                                                              console.log(object);
2551                                                                                                 if (!object.match(/^\{/)) {
2552                                                                                                     return false; // do not handle!!! -> later maybe in console..
2553                                                                                                 }
2554                                                                                                 console.log(object);
2555                                                                                                 var val =  JSON.parse(object);
2556                                                                                         
2557                                                                                                 if (typeof(val['hover-node']) != 'undefined') {
2558                                                                                                     this.activeNode = val['hover-node'];
2559                                                                                                     console.log('active node: ' + this.activeNode);
2560                                                                                                     return true;
2561                                                                                                 }
2562                                                                                         
2563                                                                                                  var ret = false;
2564                                                                                                  if (typeof(val['id']) != 'undefined') {
2565                                                                                                    // this.activeNode = val['id'];
2566                                                                                                     var tg = this.get('/LeftTree.model').findDropNode(val['id'], true); 
2567                                                                                                     if (!tg) {
2568                                                                                                         return false;
2569                                                                                                     }
2570                                                                                                     this.get('/LeftTree.view').selectNode(tg[0]);
2571                                                                                                     ret  = true;
2572                                                                                                     
2573                                                                                                 } 
2574                                                                                                 if (ret && typeof(val['set']) != 'undefined') {
2575                                                                                                    this.get('/LeftPanel.model').add({
2576                                                                                                         key : val['set'],
2577                                                                                                         val : val['value']
2578                                                                                                     });
2579                                                                                                     //console.log('active node: ' + this.activeNode);
2580                                                                                                     
2581                                                                                                 }
2582                                                                                                 //Seed.print('a:'+a);
2583                                                                                                 //Seed.print('b:'+b);
2584                                                                                                 //Seed.print('c:'+c);
2585                                                                                                 return ret;
2586                                                                                         },
2587                                                                                         "drag_motion":function (w, ctx,  x,   y,   time, ud) {
2588                                                                                            // console.log('DRAG MOTION'); 
2589                                                                                                 // status:
2590                                                                                                 // if lastCurrentNode == this.currentNode.. -- don't change anything..
2591                                                                                                 this.targetData = [];
2592                                                                                                 this.el.execute_script("Builder.overPos(" + x +','+ y + ");");
2593                                                                                                 
2594                                                                                                 // A) find out from drag all the places that node could be dropped.
2595                                                                                                 var src = Gtk.drag_get_source_widget(ctx);
2596                                                                                                 if (!src.dropList) {
2597                                                                                                     Gdk.drag_status(ctx, 0, time);
2598                                                                                                     return true;
2599                                                                                                 }
2600                                                                                                 // b) get what we are over.. (from activeNode)
2601                                                                                                 // tree is empty.. - list should be correct..
2602                                                                                                 if (!this.get('/LeftTree.model').currentTree) {
2603                                                                                                     Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2604                                                                                                     return true;
2605                                                                                                     
2606                                                                                                 }
2607                                                                                                 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
2608                                                                                                 
2609                                                                                                 var tg = this.get('/LeftTree.model').findDropNode(this.activeNode, src.dropList);
2610                                                                                                 console.dump(tg);
2611                                                                                                 if (!tg.length) {
2612                                                                                                     Gdk.drag_status(ctx, 0,time);
2613                                                                                                     this.get('/LeftTree.view').highlight(false);
2614                                                                                                     return true;
2615                                                                                                 }
2616                                                                                                  
2617                                                                                                 // if we have a target..
2618                                                                                                 // -> highlight it! (in browser)
2619                                                                                                 // -> highlight it! (in tree)
2620                                                                                                 
2621                                                                                                 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2622                                                                                                 this.get('/LeftTree.view').highlight(tg);
2623                                                                                                 this.targetData = tg;
2624                                                                                                 // for tree we should handle this...
2625                                                                                                 return true;
2626                                                                                         },
2627                                                                                         "drag_drop":function (w, ctx, x, y,time, ud) {
2628                                                                                                 print("TARGET: drag-drop");
2629                                                                                                 var is_valid_drop_site = true;
2630                                                                                                 
2631                                                                                                  
2632                                                                                                 Gtk.drag_get_data
2633                                                                                                 (
2634                                                                                                         w,         /* will receive 'drag-data-received' signal */
2635                                                                                                         ctx,        /* represents the current state of the DnD */
2636                                                                                                         this.get('/Window').atoms["STRING"],    /* the target type we want */
2637                                                                                                         time            /* time stamp */
2638                                                                                                 );
2639                                                                                                                 
2640                                                                                                                 
2641                                                                                                                 /* No target offered by source => error */
2642                                                                                                                
2643                                                                                         
2644                                                                                                 return  is_valid_drop_site;
2645                                                                                         },
2646                                                                                         "drag_data_received":function (w, ctx,  x,  y, sel_data,  target_type,  time, ud) 
2647                                                                                             {
2648                                                                                                 print("Browser: drag-data-received");
2649                                                                                                 var delete_selection_data = false;
2650                                                                                                 vardnd_success = false;
2651                                                                                                 /* Deal with what we are given from source */
2652                                                                                                 if( sel_data && sel_data.length ) {
2653                                                                                                     
2654                                                                                                     if (ctx.action == Gdk.DragAction.ASK)  {
2655                                                                                                         /* Ask the user to move or copy, then set the ctx action. */
2656                                                                                                     }
2657                                                                                         
2658                                                                                                     if (ctx.action == Gdk.DragAction.MOVE) {
2659                                                                                                         delete_selection_data = true;
2660                                                                                                     }
2661                                                                                                     var source = Gtk.drag_get_source_widget(ctx);
2662                                                                                         
2663                                                                                                     print("Browser: source.DRAGDATA? " + source.dragData);
2664                                                                                                     if (this.targetData) {
2665                                                                                                         print(this.targetData);
2666                                                                                                         this.get('/LeftTree.model').dropNode(this.targetData,  source.dragData);
2667                                                                                                     }
2668                                                                                                     
2669                                                                                                     
2670                                                                                                     
2671                                                                                                     dnd_success = true;
2672                                                                                         
2673                                                                                                 }
2674                                                                                         
2675                                                                                                 if (dnd_success == false)
2676                                                                                                 {
2677                                                                                                         Seed.print ("DnD data transfer failed!\n");
2678                                                                                                 }
2679                                                                                                 
2680                                                                                                 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
2681                                                                                                 return true;
2682                                                                                             }
2683                                                                                     }
2684                                                                                 }
2685                                                                             ]
2686                                                                         }
2687                                                                     ]
2688                                                                 },
2689                                                                 {
2690                                                                     xtype: Gtk.VBox,
2691                                                                     pack : "add",
2692                                                                     id : "RightGtkView",
2693                                                                     renderJS : function(data, withDebug)
2694                                                                     {
2695                                                                          if (!data) {
2696                                                                                      return; 
2697                                                                         }
2698                                                                         this.withDebug = false;
2699                                                                         
2700                                                                         if (this.renderedEl) {
2701                                                                             this.get('view').el.remove(this.renderedEl);
2702                                                                             this.renderedEl.destroy();
2703                                                                             this.renderedEl = false;
2704                                                                         }
2705                                                                         
2706                                                                         var tree =  this.get('/LeftTree.model').toJS(false,true)[0];
2707                                                                         // in theory tree is actually window..  
2708                                                                        try {
2709                                                                         this.renderedEl = this.viewAdd(tree.items[0], this.get('view').el);
2710                                                                       } catch (e) {
2711                                                                          print(e.message);
2712                                                                         return;
2713                                                                       }
2714                                                                         this.get('view').el.set_size_request(
2715                                                                             tree.default_width * 1 || 400, tree.default_height * 1 || 400
2716                                                                         ) ;
2717                                                                         
2718                                                                         this.renderedEl.set_size_request(
2719                                                                             tree.default_width || 600,
2720                                                                             tree.default_height || 400
2721                                                                         );
2722                                                                         this.get('view').el.show_all();
2723                                                                         
2724                                                                         
2725                                                                         
2726                                                                     },
2727                                                                     showInWindow : function() {
2728                                                                       print("GET PROEJCT");
2729                                                                         var pr = this.get('/LeftProjectTree').getActiveProject();
2730                                                                       
2731                                                                         console.log(pr.paths);
2732                                                                         return;
2733                                                                     /*
2734                                                                          var src= this.buildJS(
2735                                                                                 this.get('/LeftTree.model').toJS()[0], 
2736                                                                                 true);
2737                                                                           // show term?? 
2738                                                                     
2739                                                                     
2740                                                                         //var x = new imports.sandbox.Context();
2741                                                                         //x.add_globals();
2742                                                                         //print(src);
2743                                                                         try {
2744                                                                             Seed.check_syntax('var e = ' + src);
2745                                                                             //x.eval(src);
2746                                                                         } catch( e) {
2747                                                                             this.get('/Terminal').feed(e.message || e.toString() + "\n");
2748                                                                             this.get('/Terminal').feed(console._dump(e)+"\n");
2749                                                                             if (e.line) {
2750                                                                                 var lines = src.split("\n");
2751                                                                                 var start = Math.max(0, e.line - 10);
2752                                                                                 var end = Math.min(lines.length, e.line + 10);
2753                                                                                 for (var i =start ; i < end; i++) {
2754                                                                                     if (i == e.line) {
2755                                                                                         this.get('/Terminal').feed(">>>>>" + lines[i] + "\n");
2756                                                                                         continue;
2757                                                                                     }
2758                                                                                     this.get('/Terminal').feed(lines[i] + "\n");
2759                                                                                 }
2760                                                                                 
2761                                                                             }
2762                                                                             
2763                                                                             return;
2764                                                                         }
2765                                                                          this.get('/BottomPane').el.set_current_page(1);
2766                                                                         this.get('/Terminal').el.fork_command( null , [], [], "/tmp", false,false,false); 
2767                                                                         var cmd = "/usr/bin/seed /tmp/BuilderGtkView.js\n";
2768                                                                         this.get('/Terminal').el.feed_child(cmd, cmd.length);
2769                                                                          /*
2770                                                                         var _top = x.get_global_object()._top;
2771                                                                         
2772                                                                         _top.el.set_screen(Gdk.Screen.get_default()); // just in case..
2773                                                                         _top.el.show_all();
2774                                                                         if (_top.el.popup) {
2775                                                                             _top.el.popup(null, null, null, null, 3, null);
2776                                                                         }
2777                                                                     */
2778                                                                     },
2779                                                                     viewAdd : function(item, par)
2780                                                                             {
2781                                                                         // does something similar to xobject..
2782                                                                         item.pack = (typeof(item.pack) == 'undefined') ?  'add' : item.pack;
2783                                                                         
2784                                                                         if (item.pack===false || item.pack === 'false') {  // no ;
2785                                                                             return;
2786                                                                         }
2787                                                                         print("CREATE: " + item['|xns'] + '.' + item['xtype']);
2788                                                                         var ns = imports.gi[item['|xns']];
2789                                                                         var ctr = ns[item['xtype']];
2790                                                                         var ctr_args = { };
2791                                                                         for(var k in item) {
2792                                                                             var kv = item[k];
2793                                                                             if (typeof(kv) == 'object' || typeof(kv) == 'function') {
2794                                                                                 continue;
2795                                                                             }
2796                                                                             if ( 
2797                                                                                 k == 'pack' ||
2798                                                                                 k == 'items' ||
2799                                                                                 k == 'id' ||
2800                                                                                 k == 'xtype' ||
2801                                                                                 k == 'xdebug' ||
2802                                                                                 k == 'xns' ||
2803                                                                                 k == '|xns'
2804                                                                             ) {
2805                                                                                 continue;
2806                                                                             }
2807                                                                     
2808                                                                         if (k[0] == '|' && typeof(kv) == 'string') {
2809                                                                     
2810                                                                                 if (kv.match(new RegExp('function'))) {
2811                                                                                         continue;
2812                                                                                     }
2813                                                                                  print("WASL " + k + '=' + kv);
2814                                                                                 try {
2815                                                                                         eval( 'kv = ' + kv);
2816                                                                                 } catch(e) {    continue; }
2817                                                                                     
2818                                                                                 k = k.substring(1);
2819                                                                                   print(k + '=' + kv);
2820                                                                         }
2821                                                                             if (k[0] == '|') { // should be boolean or number..
2822                                                                                 k = k.substring(1);
2823                                                                                 print(k + '=' + kv);
2824                                                                             }
2825                                                                              
2826                                                                         if (k == 'show_tabs') { // force tab showing for notebooks.
2827                                                                                kv = true;
2828                                                                             }
2829                                                                             ctr_args[k] = kv;
2830                                                                             
2831                                                                         } 
2832                                                                         
2833                                                                         
2834                                                                         var el = new ctr(ctr_args);
2835                                                                         
2836                                                                         //print("PACK");
2837                                                                         //console.dump(item.pack);
2838                                                                         
2839                                                                         
2840                                                                         
2841                                                                         
2842                                                                         var args = [];
2843                                                                         var pack_m  = false;
2844                                                                         if (typeof(item.pack) == 'string') {
2845                                                                              
2846                                                                             item.pack.split(',').forEach(function(e, i) {
2847                                                                                 
2848                                                                                 if (e == 'false') { args.push( false); return; }
2849                                                                                 if (e == 'true') {  args.push( true);  return; }
2850                                                                                 if (!isNaN(parseInt(e))) { args.push( parseInt(e)); return; }
2851                                                                                 args.push(e);
2852                                                                             });
2853                                                                             //print(args.join(","));
2854                                                                             
2855                                                                             pack_m = args.shift();
2856                                                                         } else {
2857                                                                             pack_m = item.pack.shift();
2858                                                                             args = item.pack;
2859                                                                         }
2860                                                                         
2861                                                                         // handle error.
2862                                                                         if (pack_m && typeof(par[pack_m]) == 'undefined') {
2863                                                                             throw {
2864                                                                                     name: "ArgumentError", 
2865                                                                                     message : 'pack method not available : ' + par.id + " : " + par + '.' +  pack_m +
2866                                                                                             "ADDING : " + item.id + " " +  el
2867                                                                                         
2868                                                                             };
2869                                                                     
2870                                                                             return;
2871                                                                         }
2872                                                                         
2873                                                                         console.dump(args);
2874                                                                         args.unshift(el);
2875                                                                         //if (XObject.debug) print(pack_m + '[' + args.join(',') +']');
2876                                                                         //Seed.print('args: ' + args.length);
2877                                                                         if (pack_m) {
2878                                                                             par[pack_m].apply(par, args);
2879                                                                         }
2880                                                                         
2881                                                                         var _this = this;
2882                                                                         item.items = item.items || [];
2883                                                                         item.items.forEach(function(ch) {
2884                                                                             _this.viewAdd(ch, el);
2885                                                                         });
2886                                                                         
2887                                                                         
2888                                                                         
2889                                                                         // add the signal handlers.
2890                                                                         // is it a widget!?!!?
2891                                                                        
2892                                                                         
2893                                                                         try {
2894                                                                              
2895                                                                             
2896                                                                             el.signal.expose_event.connect(XObject.createDelegate(this.widgetExposeEvent, this, [ item  ], true));
2897                                                                             el.signal.drag_motion.connect(XObject.createDelegate(this.widgetDragMotionEvent, this,[ item  ], true));
2898                                                                             el.signal.drag_drop.connect(XObject.createDelegate(this.widgetDragDropEvent, this, [ item  ], true));
2899                                                                             el.signal.button_press_event.connect(XObject.createDelegate(this.widgetPressEvent, this, [ item  ], true ));
2900                                                                       el.signal.button_release_event.connect(XObject.createDelegate(this.widgetReleaseEvent, this, [ item  ], true ));
2901                                                                         } catch(e) {
2902                                                                             // ignore!
2903                                                                            }
2904                                                                         
2905                                                                         
2906                                                                         
2907                                                                         return el;
2908                                                                         
2909                                                                     },
2910                                                                     widgetExposeEvent : function(w, evt, ud, item) {
2911                                                                         var widget = w;
2912                                                                          if (this.inRender) {
2913                                                                              return false;
2914                                                                          }
2915                                                                          
2916                                                                          if ( this.highlightWidget) {
2917                                                                               this.inRender = true;
2918                                                                               if (item.xtreepath.substring(0, this.activePath.length) == this.activePath) {
2919                                                                                      Gdk.draw_rectangle(this.highlightWidget.window, this.gc, false, this.box.x , this.box.y, this.box.w, this.box.h);
2920                                                                                 }
2921                                                                                this.inRender = false;
2922                                                                                return false;
2923                                                                          }
2924                                                                          
2925                                                                          
2926                                                                          if (this.activePath != item.xtreepath) {
2927                                                                             return false;
2928                                                                          }
2929                                                                          
2930                                                                        //  print("HIGHLIGHT: " + item.xtreepath ); // draw highlight??
2931                                                                          // work out the coords of the window..
2932                                                                          if (!this.gc) {
2933                                                                           var dr = widget.window;
2934                                                                           this.gc = (new Gdk.GC.c_new(dr));
2935                                                                           this.gc.set_rgb_fg_color(new Gdk.Color({ red: 0xFFFF, green: 0, blue : 0 }));
2936                                                                           this.gc.set_line_attributes(4,  Gdk.LineStyle.SOLID, Gdk.CapStyle.ROUND , Gdk.JoinStyle.ROUND);
2937                                                                         }
2938                                                                     
2939                                                                         
2940                                                                          var r  = evt.expose.area;
2941                                                                          // console.dump([r.x, r.y, r.width, r.height ] );
2942                                                                          //return false;
2943                                                                     //     print(widget.get_parent().toString().match(/GtkScrolledWindow/);
2944                                                                          if (widget.get_parent().toString().match(/GtkScrolledWindow/)) { // eak
2945                                                                              // happens with gtkscrollview embedded stuff..
2946                                                                              var np =this.activePath.split(':');
2947                                                                              np.pop();
2948                                                                              this.activePath = np.join(':');
2949                                                                              this.renderedEl.queue_draw();
2950                                                                              return true;
2951                                                                     
2952                                                                             
2953                                                                          }
2954                                                                     
2955                                                                            
2956                                                                          
2957                                                                          
2958                                                                           this.box = {
2959                                                                             x : r.x - 2,
2960                                                                             y : r.y - 2,
2961                                                                             w: r.width + 4,
2962                                                                             h: r.height + 4
2963                                                                           }; 
2964                                                                           // let's draw it..
2965                                                                           this.inRender = true;
2966                                                                     
2967                                                                           
2968                                                                           this.highlightWidget = widget;
2969                                                                         
2970                                                                         
2971                                                                      
2972                                                                     
2973                                                                         //  print("DRAW BOX");
2974                                                                            //console.dump(this.box);
2975                                                                           Gdk.draw_rectangle(widget.window, this.gc, false, this.box.x , this.box.y, this.box.w,this.box.h);
2976                                                                                 this.inRender = false;
2977                                                                                 return false;
2978                                                                     },
2979                                                                     widgetDragMotionEvent : function() {
2980                                                                          print("WIDGET DRAGMOTION"); 
2981                                                                                 return true;
2982                                                                     },
2983                                                                     widgetDragDropEvent : function() {
2984                                                                           print("WIDGET DRAGDROP"); 
2985                                                                                 return true;
2986                                                                     },
2987                                                                     widgetPressEvent : function(w,e,u,d) {
2988                                                                          if (this.get('view').pressed) {
2989                                                                             return false;
2990                                                                          }
2991                                                                     this.get('view').pressed = true;
2992                                                                           print("WIDGET PRESS " + d.xtreepath );       
2993                                                                               this.get('/LeftTree.view').selectNode(   d.xtreepath );        
2994                                                                                 return false;
2995                                                                     },
2996                                                                     widgetReleaseEvent : function() {
2997                                                                         this.get('view').pressed = false;
2998                                                                        return false;
2999                                                                     },
3000                                                                     redraw : function() {
3001                                                                        this.highlightWidget = false;
3002                                                                         print("REDRAW CALLED");
3003                                                                         this.activePath = this.get('/LeftTree').getActivePath();
3004                                                                         if (this.renderedEl) {
3005                                                                           print("QUEUE DRAW CALLING");
3006                                                                           this.renderedEl.queue_draw();
3007                                                                        }
3008                                                                     },
3009                                                                     items : [
3010                                                                         {
3011                                                                             xtype: Gtk.HBox,
3012                                                                             pack : "pack_start,false,true,0",
3013                                                                             items : [
3014                                                                                 {
3015                                                                                     xtype: Gtk.Button,
3016                                                                                     pack : "pack_start,false,false,0",
3017                                                                                     label : "Run The Application",
3018                                                                                     listeners : {
3019                                                                                         "button_press_event":function (self, event) {
3020                                                                                           // call render on left tree - with special option!?!
3021                                                                                          
3022                                                                                         
3023                                                                                         
3024                                                                                                 print("GET PROEJCT");
3025                                                                                                 var pr = this.get('/LeftProjectTree').getActiveProject();
3026                                                                                           
3027                                                                                         var dir = '';
3028                                                                                          for (var i in pr.paths) { 
3029                                                                                               dir = i;
3030                                                                                               break;
3031                                                                                           }
3032                                                                                            var runner = GLib.path_get_dirname (__script_path__) + '/gtkrun.js'; 
3033                                                                                            print ("RUN DIR:" + dir);
3034                                                                                             this.get('/BottomPane').el.show();
3035                                                                                            this.get('/BottomPane').el.set_current_page(1);
3036                                                                                             this.get('/Terminal').el.fork_command( null , [], [], GLib.path_get_dirname (__script_path__) 
3037                                                                                                 , false,false,false); 
3038                                                                                             var cmd = "/usr/bin/seed " + runner + " " + dir + "\n";
3039                                                                                             this.get('/Terminal').el.feed_child(cmd, cmd.length);
3040                                                                                             return false;
3041                                                                                           
3042                                                                                         
3043                                                                                         }
3044                                                                                     }
3045                                                                                 }
3046                                                                             ]
3047                                                                         },
3048                                                                         {
3049                                                                             xtype: Gtk.ScrolledWindow,
3050                                                                             pack : "add",
3051                                                                             id : "view-sw",
3052                                                                             shadow_type : Gtk.ShadowType.IN,
3053                                                                             init : function() {
3054                                                                                 XObject.prototype.init.call(this);
3055                                                                              this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
3056                                                                             },
3057                                                                             items : [
3058                                                                                 {
3059                                                                                     xtype: Gtk.EventBox,
3060                                                                                     pack : "add_with_viewport",
3061                                                                                     init : function() {
3062                                                                                         XObject.prototype.init.call(this);
3063                                                                                     this.el.modify_bg(Gtk.StateType.NORMAL, new Gdk.Color({
3064                                                                                                 red: 0x9F00, green: 0xB800 , blue : 0xA800
3065                                                                                                }));
3066                                                                                     },
3067                                                                                     items : [
3068                                                                                         {
3069                                                                                             xtype: Gtk.Fixed,
3070                                                                                             pack : "add",
3071                                                                                             init : function() {
3072                                                                                                 XObject.prototype.init.call(this);
3073                                                                                                 //this.el.set_hadjustment(this.parent.el.get_hadjustment());
3074                                                                                                 //this.el.set_vadjustment(this.parent.el.get_vadjustment());
3075                                                                                              
3076                                                                                             },
3077                                                                                             items : [
3078                                                                                                 {
3079                                                                                                     xtype: Gtk.EventBox,
3080                                                                                                     pack : "put,10,10",
3081                                                                                                     init : function() {
3082                                                                                                         //this.el =     new Gtk.Image.from_stock (Gtk.STOCK_HOME,  Gtk.IconSize.MENU);
3083                                                                                                         XObject.prototype.init.call(this);
3084                                                                                                     
3085                                                                                                                 Gtk.drag_dest_set
3086                                                                                                                 (
3087                                                                                                                         this.el,              /* widget that will accept a drop */
3088                                                                                                                         Gtk.DestDefaults.MOTION  | Gtk.DestDefaults.HIGHLIGHT,
3089                                                                                                                         null,            /* lists of target to support */
3090                                                                                                                         0,              /* size of list */
3091                                                                                                                         Gdk.DragAction.COPY         /* what to do with data after dropped */
3092                                                                                                                 );
3093                                                                                                                 
3094                                                                                                                // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
3095                                                                                                                 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
3096                                                                                                     },
3097                                                                                                     ready : false,
3098                                                                                                     getActiveNode : function(x,y)
3099                                                                                                     {
3100                                                                                                        // workout what node is here..
3101                                                                                                         return '0'; // top..
3102                                                                                                     },
3103                                                                                                     id : "view",
3104                                                                                                     listeners : {
3105                                                                                                         "drag_motion":function (self, ctx, x, y, time) {
3106                                                                                                             
3107                                                                                                                         // A) find out from drag all the places that node could be dropped.
3108                                                                                                                         var src = Gtk.drag_get_source_widget(ctx);
3109                                                                                                                         if (!src.dropList) {
3110                                                                                                                             Gdk.drag_status(ctx, 0, time);
3111                                                                                                                             return true;
3112                                                                                                                         }
3113                                                                                                                         // b) get what we are over.. (from activeNode)
3114                                                                                                                         // tree is empty.. - list should be correct..
3115                                                                                                                         if (!this.get('/LeftTree.model').currentTree) {
3116                                                                                                                             Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
3117                                                                                                                             return true;
3118                                                                                                                             
3119                                                                                                                         }
3120                                                                                                                         // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
3121                                                                                                                         var activeNode = this.getActiveNode(x, y);
3122                                                                                                                         
3123                                                                                                                         
3124                                                                                                                         var tg = this.get('/LeftTree.model').findDropNode(activeNode, src.dropList);
3125                                                                                                                         console.dump(tg);
3126                                                                                                                         if (!tg.length) {
3127                                                                                                                             Gdk.drag_status(ctx, 0,time);
3128                                                                                                                             this.get('/LeftTree.view').highlight(false);
3129                                                                                                                             return true;
3130                                                                                                                         }
3131                                                                                                                          
3132                                                                                                                         // if we have a target..
3133                                                                                                                         // -> highlight it! (in browser)
3134                                                                                                                         // -> highlight it! (in tree)
3135                                                                                                                         
3136                                                                                                                         Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
3137                                                                                                                         this.get('/LeftTree.view').highlight(tg);
3138                                                                                                                         this.targetData = tg;
3139                                                                                                                         // for tree we should handle this...
3140                                                                                                                         return true;
3141                                                                                                         },
3142                                                                                                         "drag_drop":function (self,ctx, x, y, time) {
3143                                                                                                                 Seed.print("TARGET: drag-drop");
3144                                                                                                                 var is_valid_drop_site = true;
3145                                                                                                                 
3146                                                                                                                  
3147                                                                                                                 Gtk.drag_get_data
3148                                                                                                                 (
3149                                                                                                                         self,         /* will receive 'drag-data-received' signal */
3150                                                                                                                         ctx,        /* represents the current state of the this.gDnD */
3151                                                                                                                         this.get('/Window').atoms["STRING"],    /* the target type we want */
3152                                                                                                                         time            /* time stamp */
3153                                                                                                                 );
3154                                                                                                                 
3155                                                                                                                 
3156                                                                                                                 /* No target offered by source => error */
3157                                                                                                                
3158                                                                                                         
3159                                                                                                                 return  is_valid_drop_site;
3160                                                                                                           
3161                                                                                                         },
3162                                                                                                         "drag_data_received":function (w, ctx,  x,  y, sel_data,  target_type,  time, ud) 
3163                                                                                                             {
3164                                                                                                                 Seed.print("GtkView: drag-data-received");
3165                                                                                                                 var delete_selection_data = false;
3166                                                                                                                 var dnd_success = false;
3167                                                                                                                 /* Deal with what we are given from source */
3168                                                                                                                 if( sel_data && sel_data.length ) {
3169                                                                                                                     
3170                                                                                                                     if (ctx.action == Gdk.DragAction.ASK)  {
3171                                                                                                                         /* Ask the user to move or copy, then set the ctx action. */
3172                                                                                                                     }
3173                                                                                                         
3174                                                                                                                     if (ctx.action == Gdk.DragAction.MOVE) {
3175                                                                                                                         delete_selection_data = true;
3176                                                                                                                     }
3177                                                                                                                     var source = Gtk.drag_get_source_widget(ctx);
3178                                                                                                         
3179                                                                                                                     Seed.print("Browser: source.DRAGDATA? " + source.dragData);
3180                                                                                                                     if (this.targetData) {
3181                                                                                                                         Seed.print(this.targetData);
3182                                                                                                                         this.get('/LeftTree.model').dropNode(this.targetData,  source.dragData);
3183                                                                                                                     }
3184                                                                                                                     
3185                                                                                                                     
3186                                                                                                                     
3187                                                                                                                     dnd_success = true;
3188                                                                                                         
3189                                                                                                                 }
3190                                                                                                         
3191                                                                                                                 if (dnd_success == false)
3192                                                                                                                 {
3193                                                                                                                         Seed.print ("DnD data transfer failed!\n");
3194                                                                                                                 }
3195                                                                                                                 
3196                                                                                                                 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
3197                                                                                                                 return true;
3198                                                                                                             },
3199                                                                                                         "button_press_event":function (self, event) {
3200                                                                                                           this.pressed = false;
3201                                                                                                             return false;
3202                                                                                                         }
3203                                                                                                     }
3204                                                                                                 }
3205                                                                                             ]
3206                                                                                         }
3207                                                                                     ]
3208                                                                                 }
3209                                                                             ]
3210                                                                         }
3211                                                                     ]
3212                                                                 }
3213                                                             ]
3214                                                         },
3215                                                         {
3216                                                             xtype: Gtk.ScrolledWindow,
3217                                                             pack : "add",
3218                                                             id : "Help",
3219                                                             items : [
3220                                                                 {
3221                                                                     xtype: WebKit.WebView,
3222                                                                     pack : "add",
3223                                                                     id : "help-view",
3224                                                                     init : function() {
3225                                                                         XObject.prototype.init.call(this);
3226                                                                        this.get('/Window.help-view').el.open(
3227                                                                          "http://devel.akbkhome.com/seed/");
3228                                                                     
3229                                                                     }
3230                                                                 }
3231                                                             ]
3232                                                         }
3233                                                     ]
3234                                                 }
3235                                             ]
3236                                         },
3237                                         {
3238                                             xtype: Gtk.Notebook,
3239                                             pack : "add",
3240                                             init : function() {
3241                                                 XObject.prototype.init.call(this);
3242                                                 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Code Editor" }));
3243                                                         this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Console" }));
3244                                             },
3245                                             id : "BottomPane",
3246                                             items : [
3247                                                 {
3248                                                     xtype: Gtk.ScrolledWindow,
3249                                                     pack : "add",
3250                                                     id : "RightEditor",
3251                                                     items : [
3252                                                         {
3253                                                             xtype: GtkSource.View,
3254                                                             pack : "add",
3255                                                             id : "view",
3256                                                             init : function() {
3257                                                                 XObject.prototype.init.call(this);
3258                                                                  var description = Pango.Font.description_from_string("monospace")
3259                                                                 description.set_size(8000);
3260                                                                 this.el.modify_font(description);
3261                                                             
3262                                                             },
3263                                                             load : function(str) {
3264                                                             
3265                                                             // show the help page for the active node..
3266                                                                this.get('/Window.view-help-nb').el.set_current_page(1);
3267                                                             
3268                                                             // get the active element being edited.
3269                                                                var xtype = this.get('/LeftTree.model').file.guessName(
3270                                                                 this.get('/MidPropTree').activeElement);
3271                                                             // now load the help info in the page..
3272                                                                this.get('/Window.help-view').el.open(
3273                                                                  "http://devel.akbkhome.com/seed/" + xtype + ".html");
3274                                                             
3275                                                             
3276                                                                this.get('/BottomPane').el.set_current_page(0);
3277                                                                 this.el.get_buffer().set_text(str, str.length);
3278                                                                 var lm = GtkSource.LanguageManager.get_default();
3279                                                                 
3280                                                                 this.el.get_buffer().set_language(lm.get_language('js'));
3281                                                                 var buf = this.el.get_buffer();
3282                                                                 var cursor = buf.get_mark("insert");
3283                                                                 var iter= new Gtk.TextIter;
3284                                                                 buf.get_iter_at_mark(iter, cursor);
3285                                                                 iter.set_line(1);
3286                                                                 iter.set_line_offset(4);
3287                                                                 buf.move_mark(cursor, iter);
3288                                                                 
3289                                                                 
3290                                                                 cursor = buf.get_mark("selection_bound");
3291                                                                 iter= new Gtk.TextIter;
3292                                                                 buf.get_iter_at_mark(iter, cursor);
3293                                                                 iter.set_line(1);
3294                                                                 iter.set_line_offset(4);
3295                                                                 buf.move_mark(cursor, iter);
3296                                                                  
3297                                                                 this.el.grab_focus();
3298                                                             },
3299                                                             insert_spaces_instead_of_tabs : true,
3300                                                             indent_width : 4,
3301                                                             auto_indent : true,
3302                                                             show_line_numbers : true,
3303                                                             items : [
3304                                                                 {
3305                                                                     xtype: GtkSource.Buffer,
3306                                                                     pack : "set_buffer",
3307                                                                     listeners : {
3308                                                                         "changed":function (self) {
3309                                                                             var s = new Gtk.TextIter();
3310                                                                             var e = new Gtk.TextIter();
3311                                                                             this.el.get_start_iter(s);
3312                                                                             this.el.get_end_iter(e);
3313                                                                             var str = this.el.get_text(s,e,true);
3314                                                                             try {
3315                                                                                 Seed.check_syntax('var e = ' + str);
3316                                                                             } catch (e) {
3317                                                                                 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3318                                                                                     red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC
3319                                                                                    }));
3320                                                                                 print("SYNTAX ERROR IN EDITOR");   
3321                                                                                 print(e);
3322                                                                                 console.dump(e);
3323                                                                                 return;
3324                                                                             }
3325                                                                             this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3326                                                                                     red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF
3327                                                                                    }));
3328                                                                             
3329                                                                              this.get('/LeftPanel.model').changed(  str , false);
3330                                                                         }
3331                                                                     }
3332                                                                 }
3333                                                             ]
3334                                                         }
3335                                                     ]
3336                                                 },
3337                                                 {
3338                                                     xtype: Gtk.ScrolledWindow,
3339                                                     pack : "add",
3340                                                     items : [
3341                                                         {
3342                                                             xtype: Vte.Terminal,
3343                                                             pack : "add",
3344                                                             id : "Terminal",
3345                                                             feed : function(str) {
3346                                                                 this.el.feed(str,str.length);
3347                                                             }
3348                                                         }
3349                                                     ]
3350                                                 }
3351                                             ]
3352                                         }
3353                                     ]
3354                                 },
3355                                 {
3356                                     xtype: Gtk.VBox,
3357                                     pack : "pack_start,false,false",
3358                                     id : "RightPalete",
3359                                     hide : function() {
3360                                         
3361                                           this.get('buttonbar').el.show();
3362                                            this.get('viewbox').el.hide();
3363                                         print("TRIED TO HIDE");
3364                                     },
3365                                     show : function() {
3366                                         this.get('buttonbar').el.hide();
3367                                         this.get('viewbox').el.show();
3368                                        // this.get('model').expanded();
3369                                                 
3370                                     },
3371                                     provider : false,
3372                                     items : [
3373                                         {
3374                                             xtype: Gtk.VBox,
3375                                             pack : "add",
3376                                             id : "buttonbar",
3377                                             items : [
3378                                                 {
3379                                                     xtype: Gtk.Button,
3380                                                     pack : "pack_start,false,true",
3381                                                     listeners : {
3382                                                         "clicked":function (self) {
3383                                                                 this.get('/RightPalete').show();
3384                                                         }
3385                                                     },
3386                                                     items : [
3387                                                         {
3388                                                             xtype: Gtk.Image,
3389                                                             pack : "add",
3390                                                             stock : Gtk.STOCK_GOTO_FIRST,
3391                                                             icon_size : Gtk.IconSize.MENU
3392                                                         }
3393                                                     ]
3394                                                 },
3395                                                 {
3396                                                     xtype: Gtk.Label,
3397                                                     pack : "add",
3398                                                     label : "Palete",
3399                                                     angle : 270,
3400                                                     init : function() {
3401                                                         XObject.prototype.init.call(this);
3402                                                         this.el.add_events ( Gdk.EventMask.BUTTON_MOTION_MASK );
3403                                                     },
3404                                                     listeners : {
3405                                                         "enter_notify_event":function (self, event) {
3406                                                             this.get('/RightPalete').show();
3407                                                             return false;
3408                                                         }
3409                                                     }
3410                                                 }
3411                                             ]
3412                                         },
3413                                         {
3414                                             xtype: Gtk.VBox,
3415                                             pack : "add",
3416                                             id : "viewbox",
3417                                             items : [
3418                                                 {
3419                                                     xtype: Gtk.HBox,
3420                                                     pack : "pack_start,false,true",
3421                                                     items : [
3422                                                         {
3423                                                             xtype: Gtk.Label,
3424                                                             pack : "add",
3425                                                             label : "Palete"
3426                                                         },
3427                                                         {
3428                                                             xtype: Gtk.Button,
3429                                                             pack : "pack_start,false,true",
3430                                                             listeners : {
3431                                                                 "clicked":function (self) {
3432                                                                         this.get('/RightPalete').hide();
3433                                                                 }
3434                                                             },
3435                                                             items : [
3436                                                                 {
3437                                                                     xtype: Gtk.Image,
3438                                                                     pack : "add",
3439                                                                     stock : Gtk.STOCK_GOTO_LAST,
3440                                                                     icon_size : Gtk.IconSize.MENU
3441                                                                 }
3442                                                             ]
3443                                                         }
3444                                                     ]
3445                                                 },
3446                                                 {
3447                                                     xtype: Gtk.ScrolledWindow,
3448                                                     pack : "add",
3449                                                     init : function() {
3450                                                         XObject.prototype.init.call(this);
3451                                                         this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
3452                                                         this.el.set_size_request(-1,200);
3453                                                     },
3454                                                     shadow_type : Gtk.ShadowType.IN,
3455                                                     items : [
3456                                                         {
3457                                                             xtype: Gtk.TreeView,
3458                                                             pack : "add",
3459                                                             init : function() {
3460                                                                 XObject.prototype.init.call(this);
3461                                                               this.el.set_size_request(150,-1);
3462                                                                                       //  set_reorderable: [1]
3463                                                                                               
3464                                                                         var description = new Pango.FontDescription.c_new();
3465                                                                 description.set_size(8000);
3466                                                                 this.el.modify_font(description);
3467                                                                 
3468                                                                 this.selection = this.el.get_selection();
3469                                                                 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
3470                                                                // this.selection.signal['changed'].connect(function() {
3471                                                                 //    _view.listeners['cursor-changed'].apply(_view, [ _view, '']);
3472                                                                 //});
3473                                                                 // see: http://live.gnome.org/GnomeLove/DragNDropTutorial
3474                                                                  
3475                                                                 Gtk.drag_source_set (
3476                                                                         this.el,            /* widget will be drag-able */
3477                                                                         Gdk.ModifierType.BUTTON1_MASK,       /* modifier that will start a drag */
3478                                                                         null,            /* lists of target to support */
3479                                                                         0,              /* size of list */
3480                                                                         Gdk.DragAction.COPY         /* what to do with data after dropped */
3481                                                                 );
3482                                                                 //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList);
3483                                                                
3484                                                                 Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
3485                                                                 Gtk.drag_source_add_text_targets(this.el); 
3486                                                                 /*
3487                                                                 print("RP: TARGET:" + LeftTree.atoms["STRING"]);
3488                                                                 targets = new Gtk.TargetList();
3489                                                                 targets.add( LeftTree.atoms["STRING"], 0, 0);
3490                                                                 targets.add_text_targets( 1 );
3491                                                                 Gtk.drag_dest_set_target_list(this.el, LeftTree.targetList);
3492                                                                 
3493                                                                 //if you want to allow text to be output elsewhere..
3494                                                                 //Gtk.drag_source_add_text_targets(this.el);
3495                                                                 */
3496                                                                 return true; 
3497                                                             },
3498                                                             headers_visible : false,
3499                                                             enable_tree_lines : true,
3500                                                             listeners : {
3501                                                                 "drag_begin":function (self, ctx) {
3502                                                                     // we could fill this in now...
3503                                                                         Seed.print('SOURCE: drag-begin');
3504                                                                         
3505                                                                         
3506                                                                         
3507                                                                         var iter = new Gtk.TreeIter();
3508                                                                         var s = this.selection;
3509                                                                         s.get_selected(this.get('/RightPalete.model').el, iter);
3510                                                                         var path = this.get('/RightPalete.model').el.get_path(iter);
3511                                                                         
3512                                                                         var pix = this.el.create_row_drag_icon ( path);
3513                                                                             
3514                                                                                 
3515                                                                         Gtk.drag_set_icon_pixmap (ctx,
3516                                                                             pix.get_colormap(),
3517                                                                             pix,
3518                                                                             null,
3519                                                                             -10,
3520                                                                             -10);
3521                                                                         
3522                                                                         var value = new GObject.Value('');
3523                                                                         this.get('/RightPalete.model').el.get_value(iter, 0, value);
3524                                                                         if (!this.get('/RightPalete').provider) {
3525                                                                             return false;
3526                                                                         }
3527                                                                         this.el.dropList = this.get('/RightPalete').provider.getDropList(value.value);
3528                                                                         this.el.dragData = value.value;
3529                                                                         
3530                                                                         
3531                                                                         
3532                                                                         
3533                                                                         return true;
3534                                                                 },
3535                                                                 "drag_data_get":function (self, drag_context, selection_data, info, time) {
3536                                                                         //Seed.print('Palete: drag-data-get: ' + target_type);
3537                                                                         if (this.el.dragData && this.el.dragData.length ) {
3538                                                                             selection_data.set_text(this.el.dragData ,this.el.dragData.length);
3539                                                                         }
3540                                                                         
3541                                                                         
3542                                                                         //this.el.dragData = "TEST from source widget";
3543                                                                         
3544                                                                         
3545                                                                 },
3546                                                                 "drag_end":function (self, drag_context) {
3547                                                                         Seed.print('SOURCE: drag-end');
3548                                                                         this.el.dragData = false;
3549                                                                         this.el.dropList = false;
3550                                                                         this.get('/LeftTree.view').highlight(false);
3551                                                                         return true;
3552                                                                 }
3553                                                             },
3554                                                             items : [
3555                                                                 {
3556                                                                     xtype: Gtk.ListStore,
3557                                                                     pack : "set_model",
3558                                                                     init : function() {
3559                                                                         XObject.prototype.init.call(this);
3560                                                                     this.el.set_column_types ( 2, [
3561                                                                                                 GObject.TYPE_STRING, // title 
3562                                                                                                 GObject.TYPE_STRING // tip
3563                                                                                                 
3564                                                                                                 ] );
3565                                                                     },
3566                                                                     id : "model",
3567                                                                     load : function(tr,iter)
3568                                                                     {
3569                                                                         if (!iter) {
3570                                                                             this.el.clear();
3571                                                                         }
3572                                                                         //console.log('Project tree load: ' + tr.length);
3573                                                                         var citer = new Gtk.TreeIter();
3574                                                                         //this.insert(citer,iter,0);
3575                                                                         for(var i =0 ; i < tr.length; i++) {
3576                                                                             if (!iter) {
3577                                                                                 
3578                                                                                 this.el.append(citer);   
3579                                                                             } else {
3580                                                                                 this.el.insert(citer,iter,-1);
3581                                                                             }
3582                                                                             
3583                                                                             var r = tr[i];
3584                                                                             //Seed.print(r);
3585                                                                             this.el.set_value(citer, 0,  '' +  r ); // title 
3586                                                                             
3587                                                                             //this.el.set_value(citer, 1,  new GObject.Value( r)); //id
3588                                                                             //if (r.cn && r.cn.length) {
3589                                                                             //    this.load(r.cn, citer);
3590                                                                             //}
3591                                                                         }
3592                                                                         
3593                                                                         
3594                                                                     },
3595                                                                     getValue : function (iter, col) {
3596                                                                         var gval = new GObject.Value('');
3597                                                                          this.el.get_value(iter, col ,gval);
3598                                                                         return  gval.value;
3599                                                                         
3600                                                                         
3601                                                                     }
3602                                                                 },
3603                                                                 {
3604                                                                     xtype: Gtk.TreeViewColumn,
3605                                                                     pack : "append_column",
3606                                                                     init : function() {
3607                                                                         XObject.prototype.init.call(this);
3608                                                                         this.el.add_attribute(this.items[0].el , 'markup', 0 );
3609                                                                     },
3610                                                                     items : [
3611                                                                         {
3612                                                                             xtype: Gtk.CellRendererText,
3613                                                                             pack : "pack_start"
3614                                                                         }
3615                                                                     ]
3616                                                                 }
3617                                                             ]
3618                                                         }
3619                                                     ]
3620                                                 }
3621                                             ]
3622                                         }
3623                                     ]
3624                                 }
3625                             ]
3626                         }
3627                     ]
3628                 }
3629             ]
3630         }
3631     ]
3632 });
3633 Window.init();
3634 XObject.cache['/Window'] = Window;