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 GtkClutter = imports.gi.GtkClutter;
12 console = imports.console;
13 XObject = imports.XObject.XObject;
17 delete_event : function (self, event) {
18 if (!this.get('/Editor.RightEditor').save()) {
19 // no hiding with errors.
23 this.get('/Editor').activePath = false;
26 configure_event : function (self, object) {
27 this.pos = this.el.get_position();
32 show : function (self) {
34 this.el.set_uposition(this.pos.root_x,this.pos.root_y);
40 title : "Application Builder - Editor",
42 save : function (self, event) {
43 if (!this.get('/Editor.RightEditor').save()) {
44 // no hiding with errors.
47 this.get('/Editor').activePath = false;
52 XObject.prototype.init.call(this);
62 pack : "pack_start,false,true",
67 clicked : function (self) {
69 this.get('/Editor.RightEditor').save();
78 xtype: Gtk.ScrolledWindow,
82 // make sure we have an active path..
83 if (!this.get('/Editor').activePath) {
87 var str = this.get('/Editor.buffer').toString();
88 if (!this.get('/Editor.buffer').checkSyntax()) {
89 this.get('/StandardErrorDialog').show("Fix errors in code and save..");
93 this.get('/LeftPanel.model').changed( str , false);
94 this.get('/Editor').dirty = false;
95 this.get('/Editor.save_button').el.sensitive = false;
100 xtype: GtkSource.View,
102 key_release_event : function (self, event) {
104 if (event.key.keyval == 115 && (event.key.state & Gdk.ModifierType.CONTROL_MASK ) ) {
105 print("SAVE: ctrl-S pressed");
109 // print(event.key.keyval)
119 XObject.prototype.init.call(this);
120 var description = Pango.Font.description_from_string("monospace")
121 description.set_size(8000);
122 this.el.modify_font(description);
125 insert_spaces_instead_of_tabs : true,
126 load : function(str) {
128 // show the help page for the active node..
129 //this.get('/Help').show();
132 // this.get('/BottomPane').el.set_current_page(0);
133 this.el.get_buffer().set_text(str, str.length);
134 var lm = GtkSource.LanguageManager.get_default();
136 this.el.get_buffer().set_language(lm.get_language('js'));
137 var buf = this.el.get_buffer();
138 var cursor = buf.get_mark("insert");
139 var iter= new Gtk.TextIter;
140 buf.get_iter_at_mark(iter, cursor);
142 iter.set_line_offset(4);
143 buf.move_mark(cursor, iter);
146 cursor = buf.get_mark("selection_bound");
147 iter= new Gtk.TextIter;
148 buf.get_iter_at_mark(iter, cursor);
150 iter.set_line_offset(4);
151 buf.move_mark(cursor, iter);
152 this.get('/Editor').dirty = false;
153 this.el.grab_focus();
154 this.get('/Editor.save_button').el.sensitive = false;
158 return this.get('/Editor.RightEditor').save();
160 show_line_numbers : true,
163 xtype: GtkSource.Buffer,
165 changed : function (self) {
167 if(this.checkSyntax()) {
168 this.get('/Editor.save_button').el.sensitive = true;
170 // print("EDITOR CHANGED");
171 this.get('/Editor').dirty = true;
173 // this.get('/LeftPanel.model').changed( str , false);
179 checkSyntax : function() {
180 var str = this.toString();
183 // print('var res = ' + str);
184 Seed.check_syntax('var res = ' + str);
189 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
190 red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC
192 print("SYNTAX ERROR IN EDITOR");
198 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
199 red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF
204 toString : function() {
206 var s = new Gtk.TextIter();
207 var e = new Gtk.TextIter();
208 this.el.get_start_iter(s);
209 this.el.get_end_iter(e);
210 var ret = this.el.get_text(s,e,true);
211 //print("TO STRING? " + ret);
224 XObject.cache['/Editor'] = Editor;