};
public AppSettings settings = null;
+
+
+ public static Palete.ValaSource valasource;
+
public BuilderApplication ( string[] args)
{
application_id: "org.roojs.app-builder",
flags: ApplicationFlags.FLAGS_NONE
);
- BuilderApplication.windows = new Gee.ArrayList<Xcls_MainWindow>();
+ BuilderApplication.windows = new Gee.ArrayList<Xcls_MainWindow>();
+ BuilderApplication.valasource = new Palete.ValaSource();
+
+
configDirectory();
this.settings = AppSettings.factory();
var opt_context = new OptionContext ("Application Builder");
BuilderApplication.windows.add(w);
BuilderApplication.updateWindows();
+
+
}
public static void removeWindow(Xcls_MainWindow w)
BuilderApplication.windows.remove(w);
BuilderApplication.updateWindows();
+ BuilderApplication.valasource.compiled.disconnect(w.windowstate.showCompileResult);
+ BuilderApplication.valasource.compile_output.disconnect(w.windowstate.compile_results.addLine);
+
+
}
public static void updateWindows()
{
]
},
"xtype" : "SourceBuffer",
- "| bool checkSyntax" : [
+ "| bool checkSyntax" : [
" () {",
" ",
" if (this.check_running) {",
" // assume it's gtk...",
" this.check_running = true;",
" ",
- " if (!_this.window.windowstate.valasource.checkPlainFileSpawn(",
+ " if (!BuilderApplication.valasource.checkPlainFileSpawn(",
"\t _this.file,",
"\t str",
"\t )) {",
" // clear the buttons.",
" ",
" ",
- " if (! _this.window.windowstate.valasource.checkFileWithNodePropChange(",
+ " if (! BuilderApplication.valasource.checkFileWithNodePropChange(",
" _this.file,",
" _this.node,",
" _this.prop, ",
"}",
""
],
- "| string toString" : [
- " () {",
- " ",
- " Gtk.TextIter s;",
- " Gtk.TextIter e;",
- " this.el.get_start_iter(out s);",
- " this.el.get_end_iter(out e);",
- " var ret = this.el.get_text(s,e,true);",
- " //print(\"TO STRING? \" + ret);",
- " return ret;",
- "}",
- " "
- ],
"| bool highlightErrors" : [
"( Gee.HashMap<int,string> validate_res) {",
" ",
"",
"}",
""
+ ],
+ "| string toString" : [
+ " () {",
+ " ",
+ " Gtk.TextIter s;",
+ " Gtk.TextIter e;",
+ " this.el.get_start_iter(out s);",
+ " this.el.get_end_iter(out e);",
+ " var ret = this.el.get_text(s,e,true);",
+ " //print(\"TO STRING? \" + ret);",
+ " return ret;",
+ "}",
+ " "
]
}
],
},
"uint tab_width" : 4,
"xtype" : "SourceView",
- "| void load" : [
+ "| void load" : [
" (string str) {",
"",
"// show the help page for the active node..",
}
],
"xtype" : "Box",
- "| void show" : [
- "(JsRender.JsRender file, JsRender.Node? node, JsRender.NodeProp? prop)",
- "{",
- " this.reset();",
- " this.file = file; ",
- " ",
- " if (file.xtype != \"PlainFile\") {",
- " \tthis.prop = prop;",
- " this.node = node;",
- "",
- " // find the text for the node..",
- " this.view.load( prop.val );",
- " this.close_btn.el.show(); ",
- " ",
- " } else {",
- " this.view.load( file.toSource() );",
- " this.close_btn.el.hide();",
- " }",
- " ",
- "}"
- ],
"| bool saveContents" : [
" () {",
" ",
"\t}); ",
"}",
""
+ ],
+ "| void show" : [
+ "(JsRender.JsRender file, JsRender.Node? node, JsRender.NodeProp? prop)",
+ "{",
+ " this.reset();",
+ " this.file = file; ",
+ " ",
+ " if (file.xtype != \"PlainFile\") {",
+ " \tthis.prop = prop;",
+ " this.node = node;",
+ "",
+ " // find the text for the node..",
+ " this.view.load( prop.val );",
+ " this.close_btn.el.show(); ",
+ " ",
+ " } else {",
+ " this.view.load( file.toSource() );",
+ " this.close_btn.el.hide();",
+ " }",
+ " ",
+ "}"
]
}
],
// my vars (def)
public Xcls_MainWindow window;
- public string activeEditor;
- public JsRender.NodeProp? prop;
public int pos_root_x;
- public JsRender.JsRender? file;
+ public bool dirty;
public int pos_root_y;
- public int last_search_end;
- public Gtk.SourceSearchContext searchcontext;
public bool pos;
- public bool dirty;
- public signal void save ();
+ public Gtk.SourceSearchContext searchcontext;
+ public int last_search_end;
+ public JsRender.NodeProp? prop;
+ public JsRender.JsRender? file;
public JsRender.Node node;
+ public signal void save ();
+ public string activeEditor;
// ctor
public Editor()
// my vars (dec)
this.window = null;
- this.activeEditor = "";
+ this.dirty = false;
+ this.pos = false;
+ this.searchcontext = null;
+ this.last_search_end = 0;
this.prop = null;
this.file = null;
- this.last_search_end = 0;
- this.searchcontext = null;
- this.pos = false;
- this.dirty = false;
this.node = null;
+ this.activeEditor = "";
// set gobject values
this.el.homogeneous = false;
}
// user defined functions
- public void scroll_to_line (int line) {
-
- GLib.Timeout.add(500, () => {
-
- var buf = this.view.el.get_buffer();
-
- var sbuf = (Gtk.SourceBuffer) buf;
-
-
- Gtk.TextIter iter;
- sbuf.get_iter_at_line(out iter, line);
- this.view.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);
- return false;
- });
- }
- public int search (string txt) {
-
- var s = new Gtk.SourceSearchSettings();
-
- this.searchcontext = new Gtk.SourceSearchContext(this.buffer.el,s);
- this.searchcontext .set_highlight(true);
- s.set_search_text(txt);
- Gtk.TextIter beg, st,en;
-
- this.buffer.el.get_start_iter(out beg);
- this.searchcontext.forward(beg, out st, out en);
- this.last_search_end = 0;
-
- return this.searchcontext.get_occurrences_count();
-
-
-
-
- }
- public void show (JsRender.JsRender file, JsRender.Node? node, JsRender.NodeProp? prop)
- {
- this.reset();
- this.file = file;
-
- if (file.xtype != "PlainFile") {
- this.prop = prop;
- this.node = node;
-
- // find the text for the node..
- this.view.load( prop.val );
- this.close_btn.el.show();
-
- } else {
- this.view.load( file.toSource() );
- this.close_btn.el.hide();
- }
-
- }
public bool saveContents () {
return true;
+ }
+ public void show (JsRender.JsRender file, JsRender.Node? node, JsRender.NodeProp? prop)
+ {
+ this.reset();
+ this.file = file;
+
+ if (file.xtype != "PlainFile") {
+ this.prop = prop;
+ this.node = node;
+
+ // find the text for the node..
+ this.view.load( prop.val );
+ this.close_btn.el.show();
+
+ } else {
+ this.view.load( file.toSource() );
+ this.close_btn.el.hide();
+ }
+
}
public void forwardSearch (bool change_focus) {
this.view.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f);
}
+ }
+ public int search (string txt) {
+
+ var s = new Gtk.SourceSearchSettings();
+
+ this.searchcontext = new Gtk.SourceSearchContext(this.buffer.el,s);
+ this.searchcontext .set_highlight(true);
+ s.set_search_text(txt);
+ Gtk.TextIter beg, st,en;
+
+ this.buffer.el.get_start_iter(out beg);
+ this.searchcontext.forward(beg, out st, out en);
+ this.last_search_end = 0;
+
+ return this.searchcontext.get_occurrences_count();
+
+
+
+
}
public void reset () {
this.file = null;
this.searchcontext = null;
}
+ public void scroll_to_line (int line) {
+
+ GLib.Timeout.add(500, () => {
+
+ var buf = this.view.el.get_buffer();
+
+ var sbuf = (Gtk.SourceBuffer) buf;
+
+
+ Gtk.TextIter iter;
+ sbuf.get_iter_at_line(out iter, line);
+ this.view.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);
+ return false;
+ });
+ }
public class Xcls_Box2 : Object
{
public Gtk.Box el;
}
// user defined functions
- public void load (string str) {
+ public void load (string str) {
// show the help page for the active node..
//this.get('/Help').show();
// my vars (def)
- public bool check_queued;
public int error_line;
+ public bool check_queued;
public bool check_running;
// ctor
this.el = new Gtk.SourceBuffer( null );
// my vars (dec)
- this.check_queued = false;
this.error_line = -1;
+ this.check_queued = false;
this.check_running = false;
// set gobject values
}
// user defined functions
- public bool highlightErrors ( Gee.HashMap<int,string> validate_res) {
-
- this.error_line = validate_res.size;
-
- if (this.error_line < 1) {
- return true;
- }
- var tlines = this.el.get_line_count ();
- Gtk.TextIter iter;
- var valiter = validate_res.map_iterator();
- while (valiter.next()) {
-
- // print("get inter\n");
- var eline = valiter.get_key();
- if (eline > tlines) {
- continue;
- }
- this.el.get_iter_at_line( out iter, eline);
- //print("mark line\n");
- this.el.create_source_mark(valiter.get_value(), "ERR", iter);
- }
- return false;
- }
- public bool checkSyntax () {
+ public bool checkSyntax () {
if (this.check_running) {
print("Check is running\n");
// assume it's gtk...
this.check_running = true;
- if (!_this.window.windowstate.valasource.checkPlainFileSpawn(
+ if (!BuilderApplication.valasource.checkPlainFileSpawn(
_this.file,
str
)) {
// clear the buttons.
- if (! _this.window.windowstate.valasource.checkFileWithNodePropChange(
+ if (! BuilderApplication.valasource.checkFileWithNodePropChange(
_this.file,
_this.node,
_this.prop,
return true; // at present allow saving - even if it's invalid..
}
- public string toString () {
-
- Gtk.TextIter s;
- Gtk.TextIter e;
- this.el.get_start_iter(out s);
- this.el.get_end_iter(out e);
- var ret = this.el.get_text(s,e,true);
- //print("TO STRING? " + ret);
- return ret;
- }
public bool highlightErrorsJson (string type, Json.Object obj) {
Gtk.TextIter start;
Gtk.TextIter end;
+ }
+ public bool highlightErrors ( Gee.HashMap<int,string> validate_res) {
+
+ this.error_line = validate_res.size;
+
+ if (this.error_line < 1) {
+ return true;
+ }
+ var tlines = this.el.get_line_count ();
+ Gtk.TextIter iter;
+ var valiter = validate_res.map_iterator();
+ while (valiter.next()) {
+
+ // print("get inter\n");
+ var eline = valiter.get_key();
+ if (eline > tlines) {
+ continue;
+ }
+ this.el.get_iter_at_line( out iter, eline);
+ //print("mark line\n");
+ this.el.create_source_mark(valiter.get_value(), "ERR", iter);
+ }
+ return false;
+ }
+ public string toString () {
+
+ Gtk.TextIter s;
+ Gtk.TextIter e;
+ this.el.get_start_iter(out s);
+ this.el.get_end_iter(out e);
+ var ret = this.el.get_text(s,e,true);
+ //print("TO STRING? " + ret);
+ return ret;
}
}
"\tif (_this.windowstate.file == null) {",
"\t\treturn true;",
"\t}",
- "\t_this.windowstate.valasource.spawnExecute(_this.windowstate.file);",
+ "\tBuilderApplication.valasource.spawnExecute(_this.windowstate.file);",
"\t",
"\t_this.windowstate.compile_results.show(this.el,true);",
"\t",
public Xcls_statusbar_compile_spinner statusbar_compile_spinner;
// my vars (def)
- public WindowState windowstate;
public string title;
+ public WindowState windowstate;
public Project.Project project;
// ctor
if (_this.windowstate.file == null) {
return true;
}
- _this.windowstate.valasource.spawnExecute(_this.windowstate.file);
+ BuilderApplication.valasource.spawnExecute(_this.windowstate.file);
_this.windowstate.compile_results.show(this.el,true);
"xtype" : "Popover",
"| void addLine" : [
"(string str) {",
+ "\t",
+ "\tif (this.window.windowstate.project.fn != BuilderApplication.valasource.file.project.fn) {",
+ "\t\t// not our project.",
+ "\t\treturn;",
+ "\t}",
+ "\t",
"\tvar buf = (Gtk.SourceBuffer)this.sourceview.el.get_buffer();",
"\tGtk.TextIter iter;",
"\tbuf.get_end_iter (out iter);",
}
public void addLine (string str) {
+
+ if (this.window.windowstate.project.fn != BuilderApplication.valasource.file.project.fn) {
+ // not our project.
+ return;
+ }
+
var buf = (Gtk.SourceBuffer)this.sourceview.el.get_buffer();
Gtk.TextIter iter;
buf.get_end_iter (out iter);
public Xcls_DialogPluginWebkit webkit_plugin;
- public Palete.ValaSource valasource; // the spawner that runs the vala compiler.
+ //public Palete.ValaSource valasource; // the spawner that runs the vala compiler.
public Json.Object last_compile_result;
// ctor
this.children_loaded = true;
- this.valasource = new Palete.ValaSource(this.win);
-
- this.valasource.compiled.connect(this.showCompileResult);
+
+ BuilderApplication.valasource.compiled.connect(this.showCompileResult);
- this.compile_results = new Xcls_ValaCompileResults();
+ this.compile_results = new Xcls_ValaCompileResults(); // the poup dialogs with results in.
this.compile_results.window = this.win;
- this.valasource.compile_output.connect(this.compile_results.addLine);
+ BuilderApplication.valasource.compile_output.connect(this.compile_results.addLine);
this.win.statusbar_compilestatus_label.el.hide();
this.win.statusbar_run.el.hide();
this.left_tree.model.updateSelected();
this.file.save();
if (this.file.xtype=="Gtk") {
- this.valasource.checkFileSpawn(this.file);
+ BuilderApplication.valasource.checkFileSpawn(this.file);
}
});
public void showCompileResult(Json.Object obj)
{
// vala has finished compiling...
- print("vala compiled");
+ GLib.debug("vala compiled");
// stop the spinner...
-
+ if (this.project.fn != BuilderApplication.valasource.file.project.fn) {
+ GLib.debug("skip update - not our project");
+ return;
+ }
var generator = new Json.Generator ();
var n = new Json.Node(Json.NodeType.OBJECT);
//var cd = new JSCore.ClassDefinitionEmpty();
- state.valasource.checkFileWithNodePropChange(
+ BuilderApplication.valasource.checkFileWithNodePropChange(
file,
node,
prop,
public signal void compiled(Json.Object res);
public signal void compile_output(string str);
- public Xcls_MainWindow window;
+
- JsRender.JsRender file;
+ public JsRender.JsRender file;
public int line_offset = 0;
public Gee.ArrayList<Spawn> children;
- public ValaSource( Xcls_MainWindow window )
+ public ValaSource( )
{
base();
- this.window = window;
+
this.compiler = null;
this.children = new Gee.ArrayList<Spawn>();
this.compiler = new Spawn("/tmp", args);
this.compiler.complete.connect(spawnResult);
- this.window.statusbar_compile_spinner.start();
+ this.spinner(true);
try {
this.compiler.run();
} catch (GLib.SpawnError e) {
GLib.debug(e.message);
- this.window.statusbar_compile_spinner.stop();
+ this.spinner(false);
this.compiler = null;
return false;
}
+ public void spinner(bool state)
+ {
+ foreach (var win in BuilderApplication.windows) {
+ if (state) {
+ win.statusbar_compile_spinner.start();
+ } else {
+ win.statusbar_compile_spinner.stop();
+ }
+ }
+ }
+
+
public bool checkFileSpawn(JsRender.JsRender file )
{
// race condition..
try {
this.compiler = new Spawn("/tmp", args);
this.compiler.complete.connect(spawnResult);
- this.window.statusbar_compile_spinner.start();
+ this.spinner(true);
this.compiler.run();
} catch (GLib.Error e) {
GLib.debug(e.message);
- this.window.statusbar_compile_spinner.stop();
+ this.spinner(false);
this.compiler = null;
return false;
}
this.compiler = new Spawn( GLib.Environment.get_home_dir(), args);
this.compiler.output_line.connect(compile_output_line);
this.compiler.complete.connect(runResult);
- this.window.statusbar_compile_spinner.start();
+ this.spinner(true);
this.compiler.run();
this.children.add(this.compiler); //keep a reference...
} catch (GLib.Error e) {
- this.window.statusbar_compile_spinner.stop();
+ this.spinner(false);
GLib.debug(e.message);
this.compiler = null;
try {
this.compiler = new Spawn("/tmp", args);
this.compiler.complete.connect(spawnResult);
- this.window.statusbar_compile_spinner.start();
+ this.spinner(true);
this.compiler.run();
} catch (GLib.Error e) {
- this.window.statusbar_compile_spinner.stop();
+ this.spinner(false);
this.compiler = null;
return false;
}
public void spawnResult(int res, string output, string stderr)
{
- this.window.statusbar_compile_spinner.stop();
+ this.spinner(false);
try {
//GLib.debug("GOT output %s", output);