+ return true; // do not display anything...
+ },
+ console_message : function (self, object, p0, p1) {
+ print(object);
+ // console.log(object);
+ if (!object.match(/^\{/)) {
+
+ //this.get('/Terminal').feed(object);
+ return true; // do not handle!!! -> later maybe in console..
+ }
+ // console.log(object);
+ var val = JSON.parse(object);
+
+ if (typeof(val['hover-node']) != 'undefined') {
+ this.activeNode = val['hover-node'];
+ console.log('active node: ' + this.activeNode);
+ return true;
+ }
+
+ var ret = false;
+ if (typeof(val['id']) != 'undefined') {
+ // this.activeNode = val['id'];
+ var tg = this.get('/LeftTree.model').findDropNode(val['id'], true);
+ if (!tg || typeof(tg[0]) == 'undefined') {
+ return false;
+ }
+ print("SELECT node " + tg[0]);
+
+ this.get('/LeftTree.view').selectNode(tg[0]);
+ ret = true;
+
+ }
+ if (ret && typeof(val['set']) != 'undefined') {
+ this.get('/LeftPanel.model').add({
+ key : val['set'],
+ val : val['value']
+ });
+ //console.log('active node: ' + this.activeNode);
+
+ }
+ //Seed.print('a:'+a);
+ //Seed.print('b:'+b);
+ //Seed.print('c:'+c);
+ return ret;
+ },
+ drag_motion : function (w, ctx, x, y, time, ud) {
+ // console.log('DRAG MOTION');
+ // status:
+ // if lastCurrentNode == this.currentNode.. -- don't change anything..
+ this.targetData = [];
+ this.el.execute_script("Builder.overPos(" + x +','+ y + ");");
+
+ // 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 tg = this.get('/LeftTree.model').findDropNode(this.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 (w, ctx, x, y,time, ud) {
+ print("TARGET: drag-drop");
+ var is_valid_drop_site = true;
+
+
+ Gtk.drag_get_data
+ (
+ w, /* will receive 'drag-data-received' signal */
+ ctx, /* represents the current state of the DnD */
+ 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)
+ {
+ print("Browser: drag-data-received");
+ var delete_selection_data = false;
+ vardnd_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);
+
+ print("Browser: source.DRAGDATA? " + source.dragData);
+ if (this.targetData) {
+ 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;
+ },
+ create_web_view : function (self, object) {
+ print("CREATE WEB VIEW");
+ return null; //new WebKit.WebView();
+ }
+ },
+ redraws : 0,
+ id : "view",
+ pack : "add",
+ init : function() {
+ XObject.prototype.init.call(this);
+ // this may not work!?
+ var settings = this.el.get_settings();
+ settings.enable_developer_extras = true;
+
+ // this was an attempt to change the url perms.. did not work..
+ // settings.enable_file_access_from_file_uris = true;
+ // settings.enable_offline_web_application_cache - true;
+ // settings.enable_universal_access_from_file_uris = true;
+ var _this = this;
+
+ // init inspector..
+ this.el.get_inspector().signal.inspect_web_view.connect(function(wi, pg) {
+ _this.get('/BottomPane.inspector').el.show();
+ return _this.get('/BottomPane.inspector').el;
+
+ });
+
+ // FIXME - base url of script..
+ // we need it so some of the database features work.
+ this.el.load_html_string( "Render not ready" ,
+ //fixme - should be a config option!
+ // or should we catch stuff and fix it up..
+ 'http://localhost/app.Builder/'
+ );