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 = false;
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 title : "Application Builder - Editor",
61 XObject.prototype.init.call(this);
64 save : function (self, event) {
65 if (!this.get('/Editor.RightEditor').save()) {
66 // no hiding with errors.
69 this.get('/Editor').activePath = false;
80 pack : "pack_start,false,true",
83 xtype: Gtk.ToolButton,
85 clicked : function (self) {
87 this.get('/Editor.RightEditor').save();
96 xtype: Gtk.ScrolledWindow,
100 // make sure we have an active path..
101 if (!this.get('/Editor').activePath) {
105 var str = this.get('/Editor.buffer').toString();
106 if (!this.get('/Editor.buffer').checkSyntax()) {
107 this.get('/StandardErrorDialog').show("Fix errors in code and save..");
111 this.get('/LeftPanel.model').changed( str , false);
112 this.get('/Editor').dirty = false;
113 this.get('/Editor.save_button').el.sensitive = false;
118 xtype: GtkSource.View,
120 key_release_event : function (self, event) {
122 if (event.key.keyval == 115 && (event.key.state & Gdk.ModifierType.CONTROL_MASK ) ) {
123 print("SAVE: ctrl-S pressed");
127 // print(event.key.keyval)
137 XObject.prototype.init.call(this);
138 var description = Pango.Font.description_from_string("monospace")
139 description.set_size(8000);
140 this.el.modify_font(description);
143 insert_spaces_instead_of_tabs : true,
144 load : function(str) {
146 // show the help page for the active node..
147 //this.get('/Help').show();
150 // this.get('/BottomPane').el.set_current_page(0);
151 this.el.get_buffer().set_text(str, str.length);
152 var lm = GtkSource.LanguageManager.get_default();
154 this.el.get_buffer().set_language(lm.get_language('js'));
155 var buf = this.el.get_buffer();
156 var cursor = buf.get_mark("insert");
157 var iter= new Gtk.TextIter;
158 buf.get_iter_at_mark(iter, cursor);
160 iter.set_line_offset(4);
161 buf.move_mark(cursor, iter);
164 cursor = buf.get_mark("selection_bound");
165 iter= new Gtk.TextIter;
166 buf.get_iter_at_mark(iter, cursor);
168 iter.set_line_offset(4);
169 buf.move_mark(cursor, iter);
170 this.get('/Editor').dirty = false;
171 this.el.grab_focus();
172 this.get('/Editor.save_button').el.sensitive = false;
176 return this.get('/Editor.RightEditor').save();
178 show_line_numbers : true,
181 xtype: GtkSource.Buffer,
183 changed : function (self) {
185 if(this.checkSyntax()) {
186 this.get('/Editor.save_button').el.sensitive = true;
188 // print("EDITOR CHANGED");
189 this.get('/Editor').dirty = true;
191 // this.get('/LeftPanel.model').changed( str , false);
197 checkSyntax : function() {
198 var str = this.toString();
201 // print('var res = ' + str);
202 Seed.check_syntax('var res = ' + str);
207 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
208 red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC
210 print("SYNTAX ERROR IN EDITOR");
216 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
217 red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF
222 toString : function() {
224 var s = new Gtk.TextIter();
225 var e = new Gtk.TextIter();
226 this.el.get_start_iter(s);
227 this.el.get_end_iter(e);
228 var ret = this.el.get_text(s,e,true);
229 //print("TO STRING? " + ret);
242 XObject.cache['/Editor'] = Editor;