3 Pango = imports.gi.Pango;
4 GLib = imports.gi.GLib;
6 GObject = imports.gi.GObject;
7 GtkSource = imports.gi.GtkSource;
8 WebKit = imports.gi.WebKit;
10 console = imports.console;
11 XObject = imports.XObject.XObject;
15 delete_event : function (self, event) {
16 if (!this.get('/Editor.RightEditor').save()) {
17 // no hiding with errors.
21 this.get('/Editor').activePath = false;
27 if (!Editor.RightEditor.save()) {
28 // no hiding with errors.
32 _this.active_path = "";
37 configure_event : function (self, object) {
38 this.pos = this.el.get_position();
45 this.el.get_position(out _this.pos_root_x, out _this.pos_root_y);
51 show : function (self) {
53 this.el.set_uposition(this.pos.root_x,this.pos.root_y);
59 _this.el.move(this.pos_root_x,this.pos_root_y);
67 title : "Application Builder - Editor",
70 XObject.prototype.init.call(this);
73 save : function (self, event) {
74 if (!this.get('/Editor.RightEditor').save()) {
75 // no hiding with errors.
78 this.get('/Editor').activePath = false;
86 if (!Editor.RightEditor.save()) {
87 // no hiding with errors.
90 _this.active_path = "";
103 pack : "pack_start,false,true",
106 xtype: Gtk.ToolButton,
108 clicked : function (self) {
110 this.get('/Editor.RightEditor').save();
114 Editor.RightEditor.save();
125 xtype: Gtk.ScrolledWindow,
129 // make sure we have an active path..
130 if (!this.get('/Editor').activePath) {
134 var str = this.get('/Editor.buffer').toString();
135 if (!this.get('/Editor.buffer').checkSyntax()) {
136 this.get('/StandardErrorDialog').show("Fix errors in code and save..");
140 this.get('/LeftPanel.model').changed( str , false);
141 this.get('/Editor').dirty = false;
142 this.get('/Editor.save_button').el.sensitive = false;
147 print("editor.rightbutton.save");
148 if (_this.active_path.length < 1 ) {
149 print("skip - no active path");
153 var str = Editor.buffer.toString();
155 if (!Editor.buffer.checkSyntax()) {
156 print("check syntax failed");
157 //this.get('/StandardErrorDialog').show("Fix errors in code and save..");
161 // LeftPanel.model.changed( str , false);
163 _this.save_button.el.sensitive = false;
164 print("set save button grey");
171 xtype: GtkSource.View,
173 key_release_event : function (self, event) {
175 if (event.key.keyval == 115 && (event.key.state & Gdk.ModifierType.CONTROL_MASK ) ) {
176 print("SAVE: ctrl-S pressed");
180 // print(event.key.keyval)
187 if (event.key.keyval == 115 && (event.key.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
188 print("SAVE: ctrl-S pressed");
192 // print(event.key.keyval)
204 XObject.prototype.init.call(this);
205 var description = Pango.Font.description_from_string("monospace")
206 description.set_size(8000);
207 this.el.modify_font(description);
212 var description = Pango.FontDescription.from_string("monospace");
213 description.set_size(8000);
214 this.override_font(description);
218 insert_spaces_instead_of_tabs : true,
219 load : function(str) {
221 // show the help page for the active node..
222 //this.get('/Help').show();
225 // this.get('/BottomPane').el.set_current_page(0);
226 this.el.get_buffer().set_text(str, str.length);
227 var lm = GtkSource.LanguageManager.get_default();
229 this.el.get_buffer().set_language(lm.get_language('js'));
230 var buf = this.el.get_buffer();
231 var cursor = buf.get_mark("insert");
232 var iter= new Gtk.TextIter;
233 buf.get_iter_at_mark(iter, cursor);
235 iter.set_line_offset(4);
236 buf.move_mark(cursor, iter);
239 cursor = buf.get_mark("selection_bound");
240 iter= new Gtk.TextIter;
241 buf.get_iter_at_mark(iter, cursor);
243 iter.set_line_offset(4);
244 buf.move_mark(cursor, iter);
245 this.get('/Editor').dirty = false;
246 this.el.grab_focus();
247 this.get('/Editor.save_button').el.sensitive = false;
251 return this.get('/Editor.RightEditor').save();
257 Editor.RightEditor.save();
260 show_line_numbers : true,
263 xtype: GtkSource.Buffer,
265 changed : function (self) {
267 if(this.checkSyntax()) {
268 this.get('/Editor.save_button').el.sensitive = true;
270 // print("EDITOR CHANGED");
271 this.get('/Editor').dirty = true;
273 // this.get('/LeftPanel.model').changed( str , false);
281 if(this.checkSyntax()) {
282 Editor.save_button.sensitive = true;
284 // print("EDITOR CHANGED");
287 // this.get('/LeftPanel.model').changed( str , false);
296 checkSyntax : function() {
297 var str = this.toString();
300 // print('var res = ' + str);
301 Seed.check_syntax('var res = ' + str);
306 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
307 red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC
309 print("SYNTAX ERROR IN EDITOR");
315 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
316 red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF
323 // we could try running valac... ?? but it's a bit confusing..
330 toString : function() {
332 var s = new Gtk.TextIter();
333 var e = new Gtk.TextIter();
334 this.el.get_start_iter(s);
335 this.el.get_end_iter(e);
336 var ret = this.el.get_text(s,e,true);
337 //print("TO STRING? " + ret);
345 this.el.get_start_iter(out s);
346 this.el.get_end_iter(out e);
347 var ret = this.el.get_text(s,e,true);
348 //print("TO STRING? " + ret);
363 XObject.cache['/Editor'] = Editor;