+ },
+ {
+ xtype: Gtk.VBox,
+ pack : "add",
+ id : "RightGtkView",
+ renderJS : function(data, withDebug)
+ {
+ this.highlightWidget = false;
+ if (!data) {
+ return;
+ }
+ this.withDebug = false;
+
+ if (this.renderedEl) {
+ this.get('view').el.remove(this.renderedEl);
+ this.renderedEl.destroy();
+ this.renderedEl = false;
+ }
+
+ var tree = this.get('/LeftTree.model').toJS(false,true)[0];
+ // in theory tree is actually window..
+ try {
+ this.renderedEl = this.viewAdd(tree.items[0], this.get('view').el);
+ } catch (e) {
+ print(e.message);
+ return;
+ }
+ this.get('view').el.set_size_request(
+ tree.default_width * 1 || 400, tree.default_height * 1 || 400
+ ) ;
+
+ this.renderedEl.set_size_request(
+ tree.default_width || 600,
+ tree.default_height || 400
+ );
+ this.get('view').el.show_all();
+
+
+
+ },
+ showInWindow : function() {
+ print("GET PROEJCT");
+ var pr = this.get('/LeftProjectTree').getActiveProject();
+
+ console.log(pr.paths);
+ return;
+ /*
+ var src= this.buildJS(
+ this.get('/LeftTree.model').toJS()[0],
+ true);
+ // show term??
+
+
+ //var x = new imports.sandbox.Context();
+ //x.add_globals();
+ //print(src);
+ try {
+ Seed.check_syntax('var e = ' + src);
+ //x.eval(src);
+ } catch( e) {
+ this.get('/Terminal').feed(e.message || e.toString() + "\n");
+ this.get('/Terminal').feed(console._dump(e)+"\n");
+ if (e.line) {
+ var lines = src.split("\n");
+ var start = Math.max(0, e.line - 10);
+ var end = Math.min(lines.length, e.line + 10);
+ for (var i =start ; i < end; i++) {
+ if (i == e.line) {
+ this.get('/Terminal').feed(">>>>>" + lines[i] + "\n");
+ continue;
+ }
+ this.get('/Terminal').feed(lines[i] + "\n");
+ }
+
+ }
+
+ return;
+ }
+ this.get('/BottomPane').el.set_current_page(1);
+ this.get('/Terminal').el.fork_command( null , [], [], "/tmp", false,false,false);
+ var cmd = "/usr/bin/seed /tmp/BuilderGtkView.js\n";
+ this.get('/Terminal').el.feed_child(cmd, cmd.length);
+ /*
+ var _top = x.get_global_object()._top;
+
+ _top.el.set_screen(Gdk.Screen.get_default()); // just in case..
+ _top.el.show_all();
+ if (_top.el.popup) {
+ _top.el.popup(null, null, null, null, 3, null);
+ }
+ */
+ },
+ viewAdd : function(item, par)
+ {
+ // does something similar to xobject..
+ item.pack = (typeof(item.pack) == 'undefined') ? 'add' : item.pack;
+
+ if (item.pack===false || item.pack === 'false') { // no ;
+ return;
+ }
+ print("CREATE: " + item['|xns'] + '.' + item['xtype']);
+ var ns = imports.gi[item['|xns']];
+ var ctr = ns[item['xtype']];
+ var ctr_args = { };
+ for(var k in item) {
+ var kv = item[k];
+ if (typeof(kv) == 'object' || typeof(kv) == 'function') {
+ continue;
+ }
+ if (
+ k == 'pack' ||
+ k == 'items' ||
+ k == 'id' ||
+ k == 'xtype' ||
+ k == 'xdebug' ||
+ k == 'xns' ||
+ k == '|xns'
+ ) {
+ continue;
+ }
+
+ if (k[0] == '|' && typeof(kv) == 'string') {
+
+ if (kv.match(new RegExp('function'))) {
+ continue;
+ }
+ print("WASL " + k + '=' + kv);
+ try {
+ eval( 'kv = ' + kv);
+ } catch(e) { continue; }
+
+ k = k.substring(1);
+ // print(k + '=' + kv);
+ }
+ if (k[0] == '|') { // should be boolean or number..
+ k = k.substring(1);
+ //print(k + '=' + kv);
+ }
+
+ if (k == 'show_tabs') { // force tab showing for notebooks.
+ kv = true;
+ }
+ print(k + '=' + typeof(kv) + " : " + kv);
+ ctr_args[k] = kv;
+
+ }
+
+
+ var el = new ctr(ctr_args);
+
+ //print("PACK");
+ //console.dump(item.pack);
+
+
+
+
+ var args = [];
+ var pack_m = false;
+ if (typeof(item.pack) == 'string') {
+
+ item.pack.split(',').forEach(function(e, i) {
+
+ if (e == 'false') { args.push( false); return; }
+ if (e == 'true') { args.push( true); return; }
+ if (!isNaN(parseInt(e))) { args.push( parseInt(e)); return; }
+ args.push(e);
+ });
+ //print(args.join(","));
+
+ pack_m = args.shift();
+ } else {
+ pack_m = item.pack.shift();
+ args = item.pack;
+ }
+
+ // handle error.
+ if (pack_m && typeof(par[pack_m]) == 'undefined') {
+ throw {
+ name: "ArgumentError",
+ message : 'pack method not available : ' + par.id + " : " + par + '.' + pack_m +
+ "ADDING : " + item.id + " " + el
+
+ };
+
+ return;
+ }
+
+ console.dump(args);
+ args.unshift(el);
+ //if (XObject.debug) print(pack_m + '[' + args.join(',') +']');
+ //Seed.print('args: ' + args.length);
+ if (pack_m) {
+ par[pack_m].apply(par, args);
+ }
+
+ var _this = this;
+ item.items = item.items || [];
+ item.items.forEach(function(ch) {
+ _this.viewAdd(ch, el);
+ });
+
+
+
+ // add the signal handlers.
+ // is it a widget!?!!?
+
+
+ try {
+
+
+ el.signal.expose_event.connect(XObject.createDelegate(this.widgetExposeEvent, this, [ item ], true));
+ el.signal.drag_motion.connect(XObject.createDelegate(this.widgetDragMotionEvent, this,[ item ], true));
+ el.signal.drag_drop.connect(XObject.createDelegate(this.widgetDragDropEvent, this, [ item ], true));
+ el.signal.button_press_event.connect(XObject.createDelegate(this.widgetPressEvent, this, [ item ], true ));
+ el.signal.button_release_event.connect(XObject.createDelegate(this.widgetReleaseEvent, this, [ item ], true ));
+ } catch(e) {
+ // ignore!
+ }
+
+
+
+ return el;
+
+ },
+ widgetExposeEvent : function(w, evt, ud, item) {
+ var widget = w;
+ if (this.inRender) {
+ return false;
+ }
+
+ if ( this.highlightWidget) {
+ this.inRender = true;
+ if (item.xtreepath.substring(0, this.activePath.length) == this.activePath) {
+ Gdk.draw_rectangle(this.highlightWidget.window, this.gc, false, this.box.x , this.box.y, this.box.w, this.box.h);
+ }
+ this.inRender = false;
+ return false;
+ }
+
+
+ if (this.activePath != item.xtreepath) {
+ return false;
+ }
+
+ // print("HIGHLIGHT: " + item.xtreepath ); // draw highlight??
+ // work out the coords of the window..
+ if (!this.gc) {
+ var dr = widget.window;
+ this.gc = (new Gdk.GC.c_new(dr));
+ this.gc.set_rgb_fg_color(new Gdk.Color({ red: 0xFFFF, green: 0, blue : 0 }));
+ this.gc.set_line_attributes(4, Gdk.LineStyle.SOLID, Gdk.CapStyle.ROUND , Gdk.JoinStyle.ROUND);
+ }
+
+
+ var r = evt.expose.area;
+ // console.dump([r.x, r.y, r.width, r.height ] );
+ //return false;
+ // print(widget.get_parent().toString().match(/GtkScrolledWindow/);
+ if (widget.get_parent().toString().match(/GtkScrolledWindow/)) { // eak
+ // happens with gtkscrollview embedded stuff..
+ var np =this.activePath.split(':');
+ np.pop();
+ this.activePath = np.join(':');
+ this.renderedEl.queue_draw();
+ return true;
+
+
+ }
+
+
+
+
+ this.box = {
+ x : r.x - 2,
+ y : r.y - 2,
+ w: r.width + 4,
+ h: r.height + 4
+ };
+ // let's draw it..
+ this.inRender = true;
+
+
+ this.highlightWidget = widget;
+
+
+
+
+ // print("DRAW BOX");
+ //console.dump(this.box);
+ Gdk.draw_rectangle(widget.window, this.gc, false, this.box.x , this.box.y, this.box.w,this.box.h);
+ this.inRender = false;
+ return false;
+ },
+ widgetDragMotionEvent : function() {
+ print("WIDGET DRAGMOTION");
+ return true;
+ },
+ widgetDragDropEvent : function() {
+ print("WIDGET DRAGDROP");
+ return true;
+ },
+ widgetPressEvent : function(w,e,u,d) {
+ if (this.get('view').pressed) {
+ return false;
+ }
+ this.get('view').pressed = true;
+ print("WIDGET PRESS " + d.xtreepath );
+ this.get('/LeftTree.view').selectNode( d.xtreepath );
+ return false;
+ },
+ widgetReleaseEvent : function() {
+ this.get('view').pressed = false;
+ return false;
+ },
+ redraw : function() {
+ this.highlightWidget = false;
+ print("REDRAW CALLED");
+ this.activePath = this.get('/LeftTree').getActivePath();
+ if (this.renderedEl) {
+ print("QUEUE DRAW CALLING");
+ this.renderedEl.queue_draw();
+ }
+ },
+ items : [
+ {
+ xtype: Gtk.HBox,
+ pack : "pack_start,false,true,0",
+ items : [
+ {
+ xtype: Gtk.Button,
+ pack : "pack_start,false,false,0",
+ label : "Run The Application",
+ listeners : {
+ "button_press_event":function (self, event) {
+ // call render on left tree - with special option!?!
+
+ //print("GET PROEJCT");
+ var pr = this.get('/LeftProjectTree').getActiveProject();
+
+ var dir = '';
+ for (var i in pr.paths) {
+ dir = i;
+ break;
+ }
+ var runner = GLib.path_get_dirname (__script_path__) + '/gtkrun.js';
+ this.get('/Terminal').feed("RUN DIR:" + dir);
+
+ this.get('/Terminal').el.fork_command( null , [], [], GLib.path_get_dirname (__script_path__)
+ , false,false,false);
+ var cmd = "/usr/bin/seed " + runner + " " + dir + "\n";
+ this.get('/Terminal').el.feed_child(cmd, cmd.length);
+ return false;
+
+
+ }
+ }
+ }
+ ]
+ },
+ {
+ xtype: Gtk.ScrolledWindow,
+ pack : "add",
+ id : "view-sw",
+ shadow_type : Gtk.ShadowType.IN,
+ init : function() {
+ XObject.prototype.init.call(this);
+ this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
+ },
+ items : [
+ {
+ xtype: Gtk.EventBox,
+ pack : "add_with_viewport",
+ init : function() {
+ XObject.prototype.init.call(this);
+ this.el.modify_bg(Gtk.StateType.NORMAL, new Gdk.Color({
+ red: 0x9F00, green: 0xB800 , blue : 0xA800
+ }));
+ },
+ items : [
+ {
+ xtype: Gtk.Fixed,
+ pack : "add",
+ init : function() {
+ XObject.prototype.init.call(this);
+ //this.el.set_hadjustment(this.parent.el.get_hadjustment());
+ //this.el.set_vadjustment(this.parent.el.get_vadjustment());
+
+ },
+ items : [
+ {
+ xtype: Gtk.EventBox,
+ pack : "put,10,10",
+ init : function() {
+ //this.el = new Gtk.Image.from_stock (Gtk.STOCK_HOME, Gtk.IconSize.MENU);
+ XObject.prototype.init.call(this);
+
+ Gtk.drag_dest_set
+ (
+ this.el, /* widget that will accept a drop */
+ Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
+ null, /* lists of target to support */
+ 0, /* size of list */
+ Gdk.DragAction.COPY /* what to do with data after dropped */
+ );
+
+ // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
+ Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
+ },
+ ready : false,
+ getActiveNode : function(x,y)
+ {
+ // workout what node is here..
+ return '0'; // top..
+ },
+ id : "view",
+ listeners : {
+ "drag_motion":function (self, ctx, x, y, time) {
+
+ // A) find out from drag all the places that node could be dropped.
+ var src = Gtk.drag_get_source_widget(ctx);
+ if (!src.dropList) {
+ Gdk.drag_status(ctx, 0, time);
+ return true;
+ }
+ // b) get what we are over.. (from activeNode)
+ // tree is empty.. - list should be correct..
+ if (!this.get('/LeftTree.model').currentTree) {
+ Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
+ return true;
+
+ }
+ // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
+ var activeNode = this.getActiveNode(x, y);
+
+
+ var tg = this.get('/LeftTree.model').findDropNode(activeNode, src.dropList);
+ console.dump(tg);
+ if (!tg.length) {
+ Gdk.drag_status(ctx, 0,time);
+ this.get('/LeftTree.view').highlight(false);
+ return true;
+ }
+
+ // if we have a target..
+ // -> highlight it! (in browser)
+ // -> highlight it! (in tree)
+
+ Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
+ this.get('/LeftTree.view').highlight(tg);
+ this.targetData = tg;
+ // for tree we should handle this...
+ return true;
+ },
+ "drag_drop":function (self,ctx, x, y, time) {
+ Seed.print("TARGET: drag-drop");
+ var is_valid_drop_site = true;
+
+
+ Gtk.drag_get_data
+ (
+ self, /* will receive 'drag-data-received' signal */
+ ctx, /* represents the current state of the this.gDnD */
+ this.get('/Window').atoms["STRING"], /* the target type we want */
+ time /* time stamp */
+ );
+
+
+ /* No target offered by source => error */
+
+
+ return is_valid_drop_site;
+
+ },
+ "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
+ {
+ Seed.print("GtkView: drag-data-received");
+ var delete_selection_data = false;
+ var dnd_success = false;
+ /* Deal with what we are given from source */
+ if( sel_data && sel_data.length ) {
+
+ if (ctx.action == Gdk.DragAction.ASK) {
+ /* Ask the user to move or copy, then set the ctx action. */
+ }
+
+ if (ctx.action == Gdk.DragAction.MOVE) {
+ delete_selection_data = true;
+ }
+ var source = Gtk.drag_get_source_widget(ctx);
+
+ Seed.print("Browser: source.DRAGDATA? " + source.dragData);
+ if (this.targetData) {
+ Seed.print(this.targetData);
+ this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
+ }
+
+
+
+ dnd_success = true;
+
+ }
+
+ if (dnd_success == false)
+ {
+ Seed.print ("DnD data transfer failed!\n");
+ }
+
+ Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
+ return true;
+ },
+ "button_press_event":function (self, event) {
+ this.pressed = false;
+ return false;
+ }
+ }
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ },
+ {
+ xtype: Gtk.ScrolledWindow,
+ pack : "add",
+ id : "Help",
+ show : function() {
+
+ var file = this.get('/LeftTree').getActiveFile();
+ if (!file) {
+ return;
+ }
+ var activeEl = this.get('/LeftTree').getActiveElement();
+ var xtype = file.guessName( activeEl )
+ if (!xtype || !xtype.length) {
+ return;
+ }
+ this.get('/Window.view-help-nb').el.set_current_page(1);
+
+ // get the active element being edited.
+ var helpurl = file.getHelpUrl(xtype);
+
+ // now load the help info in the page..
+ this.get('help-view').el.open(helpurl);
+ },
+ items : [
+ {
+ xtype: WebKit.WebView,
+ pack : "add",
+ id : "help-view",
+ init : function() {
+ XObject.prototype.init.call(this);
+ this.get('/Window.help-view').el.open(
+ "http://devel.akbkhome.com/seed/");
+
+ },
+ zoom_level : 0.8