WebKit = imports.gi.WebKit;
Vte = imports.gi.Vte;
GtkClutter = imports.gi.GtkClutter;
+Gdl = imports.gi.Gdl;
console = imports.console;
XObject = imports.XObject.XObject;
Window=new XObject({
xtype: Gtk.Window,
- type : Gtk.WindowType.TOPLEVEL,
- title : "Application Builder",
+ listeners : {
+ delete_event : function (self, event) {
+ return false;
+ },
+ destroy : function (self) {
+ Gtk.main_quit();
+ },
+ show : function (self) {
+ print("WINDOW SHOWING - trying to hide");
+ imports.Builder.Provider.ProjectManager.ProjectManager.loadConfig();
+ this.get('/MidPropTree').hideWin();
+ this.get('/RightPalete').hide();
+ this.get('/BottomPane').el.hide();
+ //this.get('/Editor').el.show_all();
+
+ }
+ },
border_width : 0,
+ default_height : 500,
+ default_width : 800,
+ id : "Window",
+ title : "Application Builder",
init : function() {
this.atoms = {
"STRING" : Gdk.atom_intern("STRING")
},
- default_width : 800,
- default_height : 500,
- id : "Window",
setTitle : function(str) {
this.el.set_title(this.title + ' - ' + str);
},
- listeners : {
- delete_event : function (self, event) {
- return false;
- },
- destroy : function (self) {
- Gtk.main_quit();
- },
- show : function (self) {
- print("WINDOW SHOWING - trying to hide");
- imports.Builder.Provider.ProjectManager.ProjectManager.loadConfig();
- this.get('/MidPropTree').hideWin();
- this.get('/RightPalete').hide();
- this.get('/BottomPane').el.hide();
-
- }
- },
+ type : Gtk.WindowType.TOPLEVEL,
items : [
{
xtype: Gtk.VBox,
activate : function (self, event) {
var js = this.get('/LeftTree.model').toJS();
if (js && js[0]) {
- this.get('/RightBrowser.view').renderJS(js[0]);
+ this.get('/RightBrowser.view').renderJS(js[0], true);
}
return false;
}
xtype: Gtk.Expander,
listeners : {
activate : function (self) {
- var nb = this.get('/LeftTopPanel.notebook');
- if (this.el.expanded) {
- // now expanded..
-
- var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
-
-
- var model = this.get('/LeftProjectTree.combomodel');
- // print ("loading Projects?")
- //console.dump(pm.projects);
- model.loadData(pm.projects);
-
-
- nb.el.set_current_page(1);
- //pm.on('changed', function() {
- //console.log("CAUGHT project manager change");
- // _combo.model.loadData(pm.projects);
- //}
- return;
- }
- nb.el.set_current_page(0);
+ // this does not actually expand it..
+ // that is done by GTK..
+
+
+ if (!this.get('/Editor').save()) {
+ // popup!! - click handled..
+ return true;
+ }
+
+ if (!this.el.expanded) {
+ this.onExpand();
+ } else {
+ this.onCollapse();
+ }
+
},
enter_notify_event : function (self, event) {
+ return;
this.el.expanded = !this.el.expanded;
//if (this.el.expanded ) {
this.listeners.activate.call(this);
init : function() {
XObject.prototype.init.call(this);
this.el.add_events (Gdk.EventMask.BUTTON_MOTION_MASK );
+ },
+ onCollapse : function() {
+
+ var nb = this.get('/LeftTopPanel.notebook');
+ nb.el.set_current_page(0);
+ },
+ onExpand : function() {
+ var nb = this.get('/LeftTopPanel.notebook');
+ var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
+
+
+ var model = this.get('/LeftProjectTree.combomodel');
+ // print ("loading Projects?")
+ //console.dump(pm.projects);
+ model.loadData(pm.projects);
+
+
+ nb.el.set_current_page(1);
+ //pm.on('changed', function() {
+ //console.log("CAUGHT project manager change");
+ // _combo.model.loadData(pm.projects);
+ //}
+ return;
}
},
{
xtype: Gtk.Notebook,
id : "notebook",
- show_border : false,
- show_tabs : false,
pack : "pack_start,true,true",
init : function() {
XObject.prototype.init.call(this);
this.el.set_current_page(0);
},
+ show_border : false,
+ show_tabs : false,
items : [
{
xtype: Gtk.ScrolledWindow,
listeners : {
button_press_event : function (self, ev) {
console.log("button press?");
+
+ if (!this.get('/Editor').save()) {
+ // popup!! - click handled..
+ return true;
+ }
+
if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {
print("click" + ev.type);
return false;
var res = {};
this.get('/LeftTree.view').el.get_path_at_pos(ev.button.x,ev.button.y, res);
- if (!this.get('/LeftTreeMenu').el) this.get('/LeftTreeMenu').init();
+ if (!this.get('/LeftTreeMenu').el) { this.get('/LeftTreeMenu').init(); }
this.get('/LeftTreeMenu').el.set_screen(Gdk.Screen.get_default());
this.get('/LeftTreeMenu').el.show_all();
id : "model",
pack : "set_model",
changed : function(n, refresh) {
- print("MODEL CHANGED CALLED" + this.activePath);
+ // print("MODEL CHANGED CALLED" + this.activePath);
if (this.activePath) {
var iter = new Gtk.TreeIter();
this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath))
this.el.set_value(iter, 2, [GObject.TYPE_STRING, this.nodeToJSON(n)]);
}
//this.currentTree = this.toJS(false, true)[0];
+ var d = new Date();
this.file.items = this.toJS(false, false);
- print("AFTER CHANGED");
+ print ("TO JS in " + ((new Date()) - d) + "ms");
+ // print("AFTER CHANGED");
//console.dump(this.file.items);
this.file.save();
this.currentTree = this.file.items[0];
if (f.items.length && typeof(f.items[0]) == 'string') {
- this.get('/RightEditor').el.show();
- this.get('/RightEditor.view').load( f.items[0]);
+ //this.get('/RightEditor').el.show();
+ //this.get('/RightEditor.view').load( f.items[0]);
return;
}
print("LOAD");
//print("hide right editior");
- this.get('/RightEditor').el.hide();
+ //this.get('/RightEditor').el.hide();
+ this.get('/Editor').el.hide();
//print("set current tree");
this.currentTree = this.toJS(false, false)[0];
//console.dump(this.currentTree);
var nb = this.get('/LeftTopPanel.expander');
nb.el.expanded = false;
- nb.listeners.activate.call(nb);
+ nb.onCollapse();
+ //nb.listeners.activate.call(nb);
//_expander.el.set_expanded(false);
var ltm = this.get('/LeftTree.model');
},
{
xtype: Gtk.Button,
- pack : "add",
listeners : {
button_press_event : function (self, event) {
- this.get('/MidPropTree.model').showData('events');
+
+ if (!this.get('/Editor').save()) {
+ // popup!! - click handled..
+ return true;
+ }
+ this.get('/MidPropTree.model').showData('events');
return false;
}
},
+ pack : "add",
items : [
{
xtype: Gtk.HBox,
},
{
xtype: Gtk.Button,
- pack : "add",
listeners : {
button_press_event : function (self, ev) {
+
+ if (!this.get('/Editor').save()) {
+ // popup!! - click handled..
+ return true;
+ }
+
var p = this.get('/AddPropertyPopup');
if (!p.el) {
p.init();
return true;
}
},
+ pack : "add",
items : [
{
xtype: Gtk.HBox,
},
{
xtype: Gtk.ScrolledWindow,
+ editing : false,
id : "LeftPanel",
pack : "add",
- shadow_type : Gtk.ShadowType.IN,
- editing : false,
init : function() {
XObject.prototype.init.call(this);
this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
},
+ shadow_type : Gtk.ShadowType.IN,
items : [
{
xtype: Gtk.TreeView,
+ listeners : {
+ button_press_event : function (self, ev) {
+
+
+ if (!this.get('/Editor').save()) {
+ // popup!! - click handled..
+ return true;
+ }
+ var res = { };
+
+ if (!this.el.get_path_at_pos(ev.button.x,ev.button.y, res)) {
+ return false; //not on a element.
+ }
+
+ // right click.
+ if (ev.type == Gdk.EventType.BUTTON_PRESS && ev.button.button == 3) {
+ // show popup!.
+ if (res.column.title == 'value' && this.get('/LeftPanel').editing) {
+ return false;
+ }
+ //if (! this.get('/LeftPanelPopup')LeftPanelPopup.el) LeftPanelPopup.init();
+ var p = this.get('/LeftPanelPopup');
+ if (!p.el) {
+ p.init();
+ }
+
+ p.el.set_screen(Gdk.Screen.get_default());
+ p.el.show_all();
+ p.el.popup(null, null, null, null, 3, ev.button.time);
+ //Seed.print("click:" + res.column.title);
+
+
+ return false;
+ }
+
+
+ if (res.column.title != 'value') {
+ // XObject.error("column is not value?");
+ return false; // ignore.. - key click.. ??? should we do this??
+ }
+
+ // currently editing???
+ // if ( this.activePath) {
+
+ // this.activePath = false;
+ // stop editing!!!!
+ if (this.get('/Editor').dirty) {
+ //if (!this.get('/Editor.buffer').checkSyntax()) {
+ // this.get('/StandardErrorDialog').show("Fix errors in code and save..");
+ // return true;
+ // // error Dialog
+ //}
+ if (!this.get('/Editor.view').save()) {
+ return true;
+ }
+ }
+ this.get('/LeftPanel').editableColumn.items[0].el.stop_editing();
+ this.get('/LeftPanel').editing = false;
+
+ // XObject.error("Currently editing?");
+ // return false;
+ // }
+
+ var renderer = this.get('/LeftPanel').editableColumn.items[0].el; // set has_entry..
+
+ var type = this.get('/LeftPanel.model').getType(res.path.to_string());
+
+ // get options for this type -- this is to support option lists etc..
+ var provider = this.get('/LeftTree').getPaleteProvider();
+ var opts = provider.findOptions(type);
+
+ if (opts === false) {
+ // it's text etnry
+ this.get('/LeftPanel').editableColumn.setOptions([]);
+ renderer.has_entry = true;
+ } else {
+ this.get('/LeftPanel').editableColumn.setOptions(opts);
+ renderer.has_entry = false;
+ }
+ this.get('/LeftPanel.model').startEditing(res.path.to_string(), 1);
+
+ //Seed.print("click" + ev.type);
+ //console.dump(res);
+ return false;
+
+
+
+ }
+ },
id : "view",
tooltip_column : 5,
- headers_visible : false,
enable_tree_lines : true,
+ headers_visible : false,
init : function() {
XObject.prototype.init.call(this);
description.set_size(8000);
this.el.modify_font(description);
},
- listeners : {
- button_press_event : function (self, ev) {
-
-
- var res = { };
- if (!this.el.get_path_at_pos(ev.button.x,ev.button.y, res)) {
- return false; //not on a element.
- }
-
-
- if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {
-
- if (res.column.title != 'value') {
- return false; // ignore..
- }
- if ( this.get('/LeftPanel').editing) {
- return false;
- }
- var renderer = this.get('/LeftPanel').editableColumn.items[0].el; // set has_entry..
- this.get('/LeftPanel').editableColumn.items[0].el.stop_editing();
- var type = this.get('/LeftPanel.model').getType(res.path.to_string());
-
-
-
- var provider = this.get('/LeftTree').getPaleteProvider();
-
- var opts = provider.findOptions(type);
-
- if (opts === false) {
- this.get('/LeftPanel').editableColumn.setOptions([]);
- renderer.has_entry = true;
- } else {
- LeftPanel.editableColumn.setOptions(opts);
- renderer.has_entry = false;
- }
-
-
- //Seed.print("click" + ev.type);
- //console.dump(res);
- return false;
- }
-
-
-
- if (res.column.title == 'value') {
- return false;
- }
- //if (! this.get('/LeftPanelPopup')LeftPanelPopup.el) LeftPanelPopup.init();
- var p = this.get('/LeftPanelPopup');
- if (!p.el) {
- p.init();
- }
-
- p.el.set_screen(Gdk.Screen.get_default());
- p.el.show_all();
- p.el.popup(null, null, null, null, 3, ev.button.time);
- //Seed.print("click:" + res.column.title);
-
-
- return false;
- }
- },
items : [
{
xtype: Gtk.TreeStore,
this.load(data);
this.get('/LeftTree.model').changed(data, true);
- },
- editSelected : function(e) {
- print("EDIT SELECTED?");
- var iter = new Gtk.TreeIter();
- var s = this.get('/LeftPanel.view').selection;
- s.get_selected(this.get('/LeftPanel.model').el, iter);
- var m = this.get('/LeftPanel.model')
-
- var gval = new GObject.Value('');
- this.el.get_value(iter, 0 ,gval);
- var val = '' + gval.value;
-
- gval = new GObject.Value('');
- this.el.get_value(iter, 1 ,gval);
- var rval = gval.value;
- var activePath = this.el.get_path(iter).to_string();
- this.activePath = activePath ;
- // was activeIter...
- // not listener...
-
- var showEditor = false;
-
- if (val[0] == '!') {
- showEditor = true;
- }
- if (val[0] == '|') {
- if (rval.match(/function/g) || rval.match(/\n/g) || rval.length > 20) {
- showEditor = true;
- }
- }
-
- if (showEditor) {
- var _this = this;
- this.activePath = false;
- GLib.timeout_add(0, 1, function() {
- // Gdk.threads_enter();
- _this.get('/BottomPane').el.show();
- _this.get('/RightEditor').el.show();
- _this.get('/RightEditor.view').load( rval );
-
- e.editing_done();
- e.remove_widget();
- _this.activePath = activePath ;
-
- // Gdk.threads_leave();
- return false;
- });
- return;
- }
- this.get('/BottomPane').el.hide();
- this.get('/RightEditor').el.hide();
-
- //var type = this.getValue(this.el.get_path(iter).to_string(),4);
-
-
},
getIterValue : function(iter, col) {
var gval = new GObject.Value('');
getType : function(treepath) {
return this.getValue(treepath, 4);
},
- getValue : function(treepath_str, col) {
- var iter = new Gtk.TreeIter();
+ getValue : function(treepath_str, col)
+ {
+ // get's the value in a row.. - keys - returns string, values - formats it..
+
+ var iter = new Gtk.TreeIter();
this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath_str));
var gval = new GObject.Value('');
this.get('/LeftPanel.model').el.get_value(iter, col ,gval);
var val = '' + gval.value;
+
if (col != 1) {
return val;
}
var type = this.getType(this.el.get_path(iter).to_string());
- print("TYPE: " +type + " - val:" + val);
+ //print("TYPE: " +type + " - val:" + val);
switch(type.toLowerCase()) {
case 'number':
case 'uint':
]);
},
load : function(ar) {
+ // might casue problesm..
+ // this.get('/Editor.RightEditor').save();
+
+ this.get('/Editor').el.hide();
+ this.get('/Editor').activePath = false;
+
+
this.el.clear();
-
- this.get('/RightEditor').el.hide();
+
+ //this.get('/RightEditor').el.hide();
if (ar === false) {
return ;
}
return ret;
},
startEditing : function(path,col) {
+
+ // alled by menu 'edit' currently..
/**
* start editing path (or selected if not set..)
* @param {String|false} path (optional) treepath to edit - selected tree gets
* edited by default.
* @param {Number} 0 or 1 (optional)- column to edit.
*/
- var tp;
+ // fix tp to be the 'treepath' string (eg. 0/1/2...)
+ var tp;
if (typeof(path) == 'string') {
tp = new Gtk.TreePath.from_string(path);
} else {
// which colum is to be edited..
var colObj = false;
+
+ // not sure what this does..
+
if (typeof(col) == 'undefined') {
var k = this.getValue(path, 0);
+ col = 1;
colObj = (!k.length || k == '|') ?
this.get('/LeftPanel').propertyColumn : this.get('/LeftPanel').editableColumn;
} else {
// make sure the pulldown is set correctly..
// not really needed for second col...
-
- var provider = this.get('/LeftTree').getPaleteProvider();
-
- var type = this.get('/LeftPanel.model').getType(path);
- var opts = provider.findOptions(type);
- var renderer = this.get('/LeftPanel').editableColumn.items[0].el;
+ var showEditor = false;
+ this.get('/Editor').activePath = false;
+ this.get('/Editor').el.hide();
+
+ if (col) {
+ var provider = this.get('/LeftTree').getPaleteProvider();
+ var type = this.get('/LeftPanel.model').getType(path);
+ var opts = provider.findOptions(type);
+ var renderer = this.get('/LeftPanel').editableColumn.items[0].el;
+
+ if (opts === false) {
+ this.get('/LeftPanel').editableColumn.setOptions([]);
+ renderer.has_entry = true;
+ } else {
+ this.get('/LeftPanel').editableColumn.setOptions(opts);
+ renderer.has_entry = false;/// - pulldowns do not have entries
+ }
+ // determine if we should use the Text editor...
+ var keyname = this.getValue(path, 0);
+ var data_value = this.getValue(path, 1);
- if (opts === false) {
- this.get('/LeftPanel').editableColumn.setOptions([]);
- renderer.has_entry = true; /// probably does not have any effect.
- } else {
- this.get('/LeftPanel').editableColumn.setOptions(opts);
- renderer.has_entry = false;
+ if ((keyname[0] == '|') ||
+ (
+ (typeof(data_value) == 'string' ) &&
+ ( data_value.match(/function/g) || data_value.match(/\n/g)) // || (data_value.length > 20))
+ )) {
+ showEditor = true;
+ }
+ print("SHOW EDITOR" + showEditor ? 'YES' :'no');
+
}
+ var _this = this;
+ // end editing..
+ // this.get('/BottomPane').el.hide();
+ //this.get('/RightEditor').el.hide();
+
- var _this=this;
+ if (showEditor) {
+
+ this.activePath = false;
+
+ _this.get('/Editor').el.show_all();
+ GLib.timeout_add(0, 1, function() {
+
+ //_this.get('/BottomPane').el.show();
+ //_this.get('/RightEditor').el.show();
+
+ _this.get('/Editor.RightEditor.view').load( _this.getValue(path, 1) );
+
+ _this.get('/Editor').activePath = path;
+ _this.activePath = path ;
+
+ return false;
+ });
+ return;
+ }
+
+
+
+
// iter now has row...
GLib.timeout_add(0, 100, function() {
-
+ _this.activePath = path;
colObj.items[0].el.editable = true; // esp. need for col 0..
_this.get('/LeftPanel.view').el.set_cursor_on_cell(
tp,
{
xtype: Gtk.TreeViewColumn,
pack : "append_column",
+ title : "value",
init : function() {
XObject.prototype.init.call(this);
this.el.add_attribute(this.items[0].el , 'text', 3 );
this.el.add_attribute(this.items[0].el , 'sensitive', 3 );
- this.el.add_attribute(this.items[0].el , 'editable', 3 );
+ //this.el.add_attribute(this.items[0].el , 'editable', 3 );
// this.el.set_cell_data_func(cell, age_cell_data_func, NULL, NULL);
this.get('/LeftPanel').editableColumn= this;
items : [
{
xtype: Gtk.CellRendererCombo,
- pack : "pack_start",
- editable : true,
- has_entry : true,
- text_column : 0,
- init : function() {
- XObject.prototype.init.call(this);
- this.el.model = new Gtk.ListStore();
- this.el.model.set_column_types ( 1, [
- GObject.TYPE_STRING // 0 real key
- ]);
- },
listeners : {
edited : function (self, object, p0) {
this.get('/LeftPanel').editing = false;
- print("EDITED? p:" + p0 + " t:" + p0);
+ var ap = this.get('/LeftPanel.model').activePath
+ print("EDITED? " + ap + " - p:" + p0 + " t:" + p0);
this.get('/LeftPanel.model').changed(p0, true);
this.get('/LeftPanel.model').activePath = false;
+ this.el.editable = false;
},
editing_started : function (self, editable, path) {
this.get('/LeftPanel').editing = true;
// console.log('editing started');
// r.has_entry = false;
- this.get('/LeftPanel.model').editSelected(editable);
+
+ this.el.editable = false; // make sure it's not editor...
+
}
+ },
+ editable : false,
+ pack : "pack_start",
+ text_column : 0,
+ has_entry : true,
+ init : function() {
+ XObject.prototype.init.call(this);
+ this.el.model = new Gtk.ListStore();
+ this.el.model.set_column_types ( 1, [
+ GObject.TYPE_STRING // 0 real key
+ ]);
}
}
]
id : "RightBrowser",
pack : "add",
items : [
+ {
+ xtype: Gtk.HBox,
+ pack : "pack_start,false,true,0",
+ items : [
+ {
+ xtype: Gtk.Button,
+ listeners : {
+ clicked : function (self) {
+ this.get('/RightBrowser.view').renderJS(null,true);
+ }
+ },
+ label : "Redraw",
+ pack : "pack_start,false,false,0"
+ },
+ {
+ xtype: Gtk.CheckButton,
+ listeners : {
+ toggled : function (self, state) {
+ this.el.set_label(this.el.active ? "Auto Redraw On" : "Auto Redraw Off");
+ }
+ },
+ active : true,
+ id : "AutoRedraw",
+ label : "Auto Redraw On",
+ pack : "pack_start,false,false,0"
+ },
+ {
+ xtype: Gtk.Button,
+ listeners : {
+ clicked : function (self) {
+ this.get('/RightBrowser.view').redraws = 99;
+ this.get('/RightBrowser.view').renderJS(null,true);
+ }
+ },
+ label : "Full Redraw",
+ pack : "pack_start,false,false,0"
+ }
+ ]
+ },
{
xtype: Gtk.ScrolledWindow,
pack : "add",
console_message : function (self, object, p0, p1) {
print(object);
// console.log(object);
+
+
+ if (object.match(/variable/) && object.match(/Builder/)) {
+ print("got builder missing message");
+ this.refreshRequired = true;
+ this.lastRedraw = 0;
+ this.runRefresh();
+ return true;
+ }
+
+
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);
},
id : "view",
pack : "add",
+ redraws : 0,
init : function() {
XObject.prototype.init.call(this);
// this may not work!?
// we need it so some of the database features work.
this.el.load_html_string( "Render not ready" ,
//fixme - should be a config option!
- 'http://www.akbkhome.com/e/'
+ // or should we catch stuff and fix it up..
+ 'http://localhost/app.Builder/'
);
// print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
- GLib.timeout_add_seconds(0, 2, function() {
+ GLib.timeout_add_seconds(0, 1, function() {
// print("run refresh?");
_this.runRefresh();
return true;
},
- renderJS : function(data) {
+ renderJS : function(data, force) {
+
+ // this is the public redraw call..
+ // we refresh in a loop privately..
+ var autodraw = this.get('/RightBrowser.AutoRedraw').el.active;
+ if (!autodraw && !force) {
+ print("Skipping redraw - no force, and autodraw off");
+ return;
+ }
this.refreshRequired = true;
},
runRefresh : function()
{
// this is run every 2 seconds from the init..
+
+
if (!this.refreshRequired) {
// print("no refresh required");
return;
}
+ if (this.lastRedraw) {
+ // do not redraw if last redraw was less that 5 seconds ago.
+ if (((new Date()) - this.lastRedraw) < 5000) {
+ return;
+ }
+ }
+
// print("HTML RENDERING");
this.get('/BottomPane').el.show();
- this.get('/BottomPane').el.set_current_page(2);// webkit view!
+ this.get('/BottomPane').el.set_current_page(2);// webkit inspector
var js = this.get('/LeftTree.model').toJS();
return;
}
var data = js[0];
-
+ this.redraws++;
var project = this.get('/Window.LeftTree').getActiveFile().project;
//print (project.fn);
this.runhtml = this.runhtml || '';
- if (project.runhtml != this.runhtml) {
+ if ((project.runhtml != this.runhtml) || (this.redraws > 10)) {
// then we need to reload the browser using
// load_html_string..
print("LOAD HTML " + html);
this.el.load_html_string( html ,
//fixme - should be a config option!
- 'http://www.akbkhome.com/e/'
+ 'http://localhost/app.Builder/'
);
-
+ this.redraws = 0;
// should trigger load_finished! - which in truns shoudl set refresh Required;
return;
if (!this.ready) {
console.log('not loaded yet');
}
-
+ this.lastRedraw = new Date();
+
this.el.execute_script("Builder.render(" + JSON.stringify(data) + ");");
+ print( "before render" + this.lastRedraw);
+ print( "after render" + (new Date()));
}
}
*/
},
viewAdd : function(item, par)
- {
+ {
+
// does something similar to xobject..
item.pack = (typeof(item.pack) == 'undefined') ? 'add' : item.pack;
+ // pack is forced to 'false'
if (item.pack===false || item.pack === 'false') { // no ;
return;
}
+
print("CREATE: " + item['|xns'] + '.' + item['xtype']);
+
+
var type = item['|xns'] + '.' + item['xtype'];
if (item['|xns'] == 'GtkClutter') { // we can not add this yet!
return false;
}
+
var ns = imports.gi[item['|xns']];
- var ctr = ns[item['xtype']];
+ var ctr = ns[item['xtype']]; // why are we using array here..?
+
+
+
var ctr_args = { };
for(var k in item) {
var kv = item[k];
) {
continue;
}
-
+ // value is a function..
if (k[0] == '|' && typeof(kv) == 'string') {
if (kv.match(new RegExp('function'))) {
continue;
}
- print("WASL " + k + '=' + kv);
+ print("WASL " + k + '=' + kv);
try {
eval( 'kv = ' + kv);
} catch(e) { continue; }
ctr_args[k] = kv;
}
-
+ var altctr = XObject.baseXObject({ xtype: ctr} );
+ var pack_m = false;
+ if (!item.pack && altctr !== false) {
+ // try XObject.
+ print("SETTING PACK TO XObjectBase method");
+ pack_m = altctr.prototype.pack;
+
+
+ }
var el = new ctr(ctr_args);
-
+ item.el = el;
print("PACK" + item.pack);
//console.dump(item.pack);
var args = [];
- var pack_m = false;
- if (typeof(item.pack) == 'string') {
-
- item.pack.split(',').forEach(function(e, i) {
+ if (!pack_m) {
+ 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(","));
- 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;
+ pack_m = args.shift();
+ } else {
+ pack_m = item.pack.shift();
+ args = item.pack;
+ }
}
-
// handle error.
- if (pack_m && typeof(par[pack_m]) == 'undefined') {
+ if (typeof(pack_m) == 'string' && typeof(par[pack_m]) == 'undefined') {
throw {
name: "ArgumentError",
message : 'pack method not available : ' + par.id + " : " + par + '.' + pack_m +
args.unshift(el);
//if (XObject.debug) print(pack_m + '[' + args.join(',') +']');
//Seed.print('args: ' + args.length);
- if (pack_m) {
+ if (typeof(pack_m) == 'string') {
par[pack_m].apply(par, args);
+ } else if (pack_m) {
+ pack_m.call(item, par, item);
}
var _this = this;
item.items = item.items || [];
item.items.forEach(function(ch,n) {
- print ("type:" + type);
+ print ("type:" + type);
- print ("ch.pack:" + ch.pack);
+ print ("ch.pack:" + ch.pack);
+
+
if (type == 'Gtk.Table' && ch.pack == 'add') {
var c = n % item.n_columns;
var r = Math.floor(n/item.n_columns);
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 ));
+ el.signal.button_release_event.connect(XObject.createDelegate(this.widgetReleaseEvent, this, [ item ], true ));
} catch(e) {
// ignore!
}
pack : "add",
init : function() {
XObject.prototype.init.call(this);
- this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Code Editor" }));
- this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Console" }));
- this.el.set_tab_label(this.items[2].el, new Gtk.Label({ label : "Inspector" }));
+ //this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Code Editor" }));
+ this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Console" }));
+ this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Inspector" }));
},
items : [
- {
- xtype: Gtk.ScrolledWindow,
- pack : "add",
- id : "RightEditor",
- items : [
- {
- xtype: GtkSource.View,
- pack : "add",
- id : "view",
- init : function() {
- XObject.prototype.init.call(this);
- var description = Pango.Font.description_from_string("monospace")
- description.set_size(8000);
- this.el.modify_font(description);
-
- },
- load : function(str) {
-
- // show the help page for the active node..
- this.get('/Help').show();
-
-
- this.get('/BottomPane').el.set_current_page(0);
- this.el.get_buffer().set_text(str, str.length);
- var lm = GtkSource.LanguageManager.get_default();
-
- this.el.get_buffer().set_language(lm.get_language('js'));
- var buf = this.el.get_buffer();
- var cursor = buf.get_mark("insert");
- var iter= new Gtk.TextIter;
- buf.get_iter_at_mark(iter, cursor);
- iter.set_line(1);
- iter.set_line_offset(4);
- buf.move_mark(cursor, iter);
-
-
- cursor = buf.get_mark("selection_bound");
- iter= new Gtk.TextIter;
- buf.get_iter_at_mark(iter, cursor);
- iter.set_line(1);
- iter.set_line_offset(4);
- buf.move_mark(cursor, iter);
-
- this.el.grab_focus();
- },
- insert_spaces_instead_of_tabs : true,
- indent_width : 4,
- auto_indent : true,
- show_line_numbers : true,
- items : [
- {
- xtype: GtkSource.Buffer,
- pack : "set_buffer",
- listeners : {
- changed : function (self) {
- var s = new Gtk.TextIter();
- var e = new Gtk.TextIter();
- this.el.get_start_iter(s);
- this.el.get_end_iter(e);
- var str = this.el.get_text(s,e,true);
- try {
- Seed.check_syntax('var e = ' + str);
- } catch (e) {
- this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
- red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC
- }));
- print("SYNTAX ERROR IN EDITOR");
- print(e);
- console.dump(e);
- return;
- }
- this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
- red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF
- }));
-
- this.get('/LeftPanel.model').changed( str , false);
- }
- }
- }
- ]
- }
- ]
- },
{
xtype: Gtk.ScrolledWindow,
pack : "add",
items : [
{
xtype: Gtk.TreeView,
- pack : "add",
- init : function() {
- XObject.prototype.init.call(this);
- this.el.set_size_request(150,-1);
- // set_reorderable: [1]
-
- var description = new Pango.FontDescription.c_new();
- description.set_size(8000);
- this.el.modify_font(description);
-
- this.selection = this.el.get_selection();
- this.selection.set_mode( Gtk.SelectionMode.SINGLE);
- // this.selection.signal['changed'].connect(function() {
- // _view.listeners['cursor-changed'].apply(_view, [ _view, '']);
- //});
- // see: http://live.gnome.org/GnomeLove/DragNDropTutorial
-
- Gtk.drag_source_set (
- this.el, /* widget will be drag-able */
- Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
- null, /* lists of target to support */
- 0, /* size of list */
- Gdk.DragAction.COPY /* what to do with data after dropped */
- );
- //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList);
-
- Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
- Gtk.drag_source_add_text_targets(this.el);
- /*
- print("RP: TARGET:" + LeftTree.atoms["STRING"]);
- targets = new Gtk.TargetList();
- targets.add( LeftTree.atoms["STRING"], 0, 0);
- targets.add_text_targets( 1 );
- Gtk.drag_dest_set_target_list(this.el, LeftTree.targetList);
-
- //if you want to allow text to be output elsewhere..
- //Gtk.drag_source_add_text_targets(this.el);
- */
- return true;
- },
- headers_visible : false,
- enable_tree_lines : true,
listeners : {
drag_begin : function (self, ctx) {
// we could fill this in now...
this.el.dropList = false;
this.get('/LeftTree.view').highlight(false);
return true;
+ },
+ button_press_event : function (self, event) {
+
+ if (!this.get('/Editor').save()) {
+ // popup!! - click handled..
+ return true;
+ }
+ return false;
}
},
+ pack : "add",
+ enable_tree_lines : true,
+ headers_visible : false,
+ init : function() {
+ XObject.prototype.init.call(this);
+ this.el.set_size_request(150,-1);
+ // set_reorderable: [1]
+
+ var description = new Pango.FontDescription.c_new();
+ description.set_size(8000);
+ this.el.modify_font(description);
+
+ this.selection = this.el.get_selection();
+ this.selection.set_mode( Gtk.SelectionMode.SINGLE);
+ // this.selection.signal['changed'].connect(function() {
+ // _view.listeners['cursor-changed'].apply(_view, [ _view, '']);
+ //});
+ // see: http://live.gnome.org/GnomeLove/DragNDropTutorial
+
+ Gtk.drag_source_set (
+ this.el, /* widget will be drag-able */
+ Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
+ null, /* lists of target to support */
+ 0, /* size of list */
+ Gdk.DragAction.COPY /* what to do with data after dropped */
+ );
+ //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList);
+
+ Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
+ Gtk.drag_source_add_text_targets(this.el);
+ /*
+ print("RP: TARGET:" + LeftTree.atoms["STRING"]);
+ targets = new Gtk.TargetList();
+ targets.add( LeftTree.atoms["STRING"], 0, 0);
+ targets.add_text_targets( 1 );
+ Gtk.drag_dest_set_target_list(this.el, LeftTree.targetList);
+
+ //if you want to allow text to be output elsewhere..
+ //Gtk.drag_source_add_text_targets(this.el);
+ */
+ return true;
+ },
items : [
{
xtype: Gtk.ListStore,