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.activePath = '';
37 configure_event : function (self, object) {
38 this.pos = this.el.get_position();
44 _this.pos = this.get_position();
50 show : function (self) {
52 this.el.set_uposition(this.pos.root_x,this.pos.root_y);
58 this.set_uposition(this.pos_root_x,this.pos_root_y);
66 title : "Application Builder - Editor",
69 XObject.prototype.init.call(this);
72 save : function (self, event) {
73 if (!this.get('/Editor.RightEditor').save()) {
74 // no hiding with errors.
77 this.get('/Editor').activePath = false;
88 pack : "pack_start,false,true",
91 xtype: Gtk.ToolButton,
93 clicked : function (self) {
95 this.get('/Editor.RightEditor').save();
104 xtype: Gtk.ScrolledWindow,
108 // make sure we have an active path..
109 if (!this.get('/Editor').activePath) {
113 var str = this.get('/Editor.buffer').toString();
114 if (!this.get('/Editor.buffer').checkSyntax()) {
115 this.get('/StandardErrorDialog').show("Fix errors in code and save..");
119 this.get('/LeftPanel.model').changed( str , false);
120 this.get('/Editor').dirty = false;
121 this.get('/Editor.save_button').el.sensitive = false;
126 xtype: GtkSource.View,
128 key_release_event : function (self, event) {
130 if (event.key.keyval == 115 && (event.key.state & Gdk.ModifierType.CONTROL_MASK ) ) {
131 print("SAVE: ctrl-S pressed");
135 // print(event.key.keyval)
145 XObject.prototype.init.call(this);
146 var description = Pango.Font.description_from_string("monospace")
147 description.set_size(8000);
148 this.el.modify_font(description);
151 insert_spaces_instead_of_tabs : true,
152 load : function(str) {
154 // show the help page for the active node..
155 //this.get('/Help').show();
158 // this.get('/BottomPane').el.set_current_page(0);
159 this.el.get_buffer().set_text(str, str.length);
160 var lm = GtkSource.LanguageManager.get_default();
162 this.el.get_buffer().set_language(lm.get_language('js'));
163 var buf = this.el.get_buffer();
164 var cursor = buf.get_mark("insert");
165 var iter= new Gtk.TextIter;
166 buf.get_iter_at_mark(iter, cursor);
168 iter.set_line_offset(4);
169 buf.move_mark(cursor, iter);
172 cursor = buf.get_mark("selection_bound");
173 iter= new Gtk.TextIter;
174 buf.get_iter_at_mark(iter, cursor);
176 iter.set_line_offset(4);
177 buf.move_mark(cursor, iter);
178 this.get('/Editor').dirty = false;
179 this.el.grab_focus();
180 this.get('/Editor.save_button').el.sensitive = false;
184 return this.get('/Editor.RightEditor').save();
186 show_line_numbers : true,
189 xtype: GtkSource.Buffer,
191 changed : function (self) {
193 if(this.checkSyntax()) {
194 this.get('/Editor.save_button').el.sensitive = true;
196 // print("EDITOR CHANGED");
197 this.get('/Editor').dirty = true;
199 // this.get('/LeftPanel.model').changed( str , false);
205 checkSyntax : function() {
206 var str = this.toString();
209 // print('var res = ' + str);
210 Seed.check_syntax('var res = ' + str);
215 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
216 red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC
218 print("SYNTAX ERROR IN EDITOR");
224 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
225 red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF
230 toString : function() {
232 var s = new Gtk.TextIter();
233 var e = new Gtk.TextIter();
234 this.el.get_start_iter(s);
235 this.el.get_end_iter(e);
236 var ret = this.el.get_text(s,e,true);
237 //print("TO STRING? " + ret);
250 XObject.cache['/Editor'] = Editor;