X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=Builder%2FWindow.js;h=ee270cf45c44df6e5cf736544169ed3682775593;hb=119290bc3234e9ece1c64dbd72ca486d9633b5b7;hp=1ba0391bead94655c2103b350e16e6290e127dff;hpb=b6ccaa2a6934c8ebe084623ef84ba6fca4129c66;p=app.Builder.js
diff --git a/Builder/Window.js b/Builder/Window.js
index 1ba0391be..ee270cf45 100644
--- a/Builder/Window.js
+++ b/Builder/Window.js
@@ -7,13 +7,33 @@ GObject = imports.gi.GObject;
GtkSource = imports.gi.GtkSource;
WebKit = imports.gi.WebKit;
Vte = imports.gi.Vte;
+GtkClutter = imports.gi.GtkClutter;
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")
@@ -32,28 +52,10 @@ Window=new XObject({
},
- 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,
@@ -162,9 +164,6 @@ Window=new XObject({
{
xtype: Gtk.Menu,
pack : "set_submenu",
- listeners : {
-
- },
items : [
{
xtype: Gtk.MenuItem,
@@ -208,9 +207,6 @@ Window=new XObject({
{
xtype: Gtk.Menu,
pack : "set_submenu",
- listeners : {
-
- },
items : [
{
xtype: Gtk.MenuItem,
@@ -218,7 +214,7 @@ Window=new XObject({
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;
}
@@ -268,7 +264,7 @@ Window=new XObject({
html = html.replace('', project.runhtml + '');
- var jsstr = JSON.stringify(js[0]);
+ var jsstr = JSON.stringify(js[0], null, 4);
var runbuilder = '';
+
+
+ this.runhtml = this.runhtml || '';
+
+ if ((project.runhtml != this.runhtml) || (this.redraws > 10)) {
+ // then we need to reload the browser using
+ // load_html_string..
+
+ // then trigger a redraw once it's loaded..
+ this.pendingRedraw = true;
+ var runhtml = ''+ "\n" ;
+
+ this.runhtml = project.runhtml;
+ // need to modify paths
+
+
+
+ var html = imports.File.File.read(__script_path__ + '/../builder.html');
+ html = html.replace('', runhtml + this.runhtml + '');
+ print("LOAD HTML " + html);
+ this.el.load_html_string( html ,
+ //fixme - should be a config option!
+ 'http://localhost/app.Builder/'
+ );
+ this.redraws = 0;
+ // should trigger load_finished! - which in truns shoudl set refresh Required;
+ return;
+
+ }
+
+
+ this.renderedData = data;
+ var str = JSON.stringify(data) ;
+
+ 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()));
+
}
}
]
@@ -2993,19 +3156,21 @@ Window=new XObject({
this.highlightWidget = false;
this.withDebug = false;
-
- if (this.renderedEl) {
- this.get('view').el.remove(this.renderedEl);
- this.renderedEl.destroy();
- this.renderedEl = false;
+ while (this.get('view').el.get_children().length) {
+ var c = this.get('view').el.get_children()[0];
+ this.get('view').el.remove(c);
+ c.destroy();
}
- if (!data) {
- return;
+ if (!data) {
+ return;
}
+
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);
+
+ this.renderedEl = this.viewAdd(tree.items[0], this.get('view').el);
+
} catch (e) {
print(e.message);
return;
@@ -3013,11 +3178,12 @@ Window=new XObject({
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
- );
+ if (this.renderedEl) {
+ this.renderedEl.set_size_request(
+ tree.default_width || 600,
+ tree.default_height || 400
+ );
+ }
this.get('view').el.show_all();
@@ -3085,6 +3251,10 @@ Window=new XObject({
}
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_args = { };
@@ -3518,8 +3688,8 @@ Window=new XObject({
},
{
xtype: Gtk.ScrolledWindow,
- pack : "add",
id : "Help",
+ pack : "add",
show : function() {
var file = this.get('/LeftTree').getActiveFile();
@@ -3531,7 +3701,7 @@ Window=new XObject({
if (!xtype || !xtype.length) {
return;
}
- this.get('/Window.view-help-nb').el.set_current_page(1);
+ //this.get('/Window.view-help-nb').el.set_current_page(1);
// get the active element being edited.
var helpurl = file.getHelpUrl(xtype);
@@ -3560,97 +3730,15 @@ Window=new XObject({
},
{
xtype: Gtk.Notebook,
+ id : "BottomPane",
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[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" }));
},
- id : "BottomPane",
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",
@@ -3675,6 +3763,17 @@ Window=new XObject({
scrollback_lines : 1000
}
]
+ },
+ {
+ xtype: Gtk.ScrolledWindow,
+ pack : "add",
+ items : [
+ {
+ xtype: WebKit.WebView,
+ id : "inspector",
+ pack : "add"
+ }
+ ]
}
]
}