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;
11 //GtkClutter = imports.gi.GtkClutter;
13 >>>>>>> 3b915ee311c6c2f49cc4f64e158b8f1c6fc7de4b
14 console = imports.console;
15 XObject = imports.XObject.XObject;
19 delete_event : function (self, event) {
20 if (!this.get('/Editor.RightEditor').save()) {
21 // no hiding with errors.
25 this.get('/Editor').activePath = false;
28 configure_event : function (self, object) {
29 this.pos = this.el.get_position();
34 show : function (self) {
36 this.el.set_uposition(this.pos.root_x,this.pos.root_y);
42 title : "Application Builder - Editor",
44 save : function (self, event) {
45 if (!this.get('/Editor.RightEditor').save()) {
46 // no hiding with errors.
49 this.get('/Editor').activePath = false;
54 XObject.prototype.init.call(this);
64 pack : "pack_start,false,true",
70 activate : function (self) {
72 this.get('/Editor.RightEditor').save();
81 xtype: Gtk.ScrolledWindow,
85 // make sure we have an active path..
86 if (!this.get('/Editor').activePath) {
90 var str = this.get('/Editor.buffer').toString();
91 if (!this.get('/Editor.buffer').checkSyntax()) {
92 this.get('/StandardErrorDialog').show("Fix errors in code and save..");
96 this.get('/LeftPanel.model').changed( str , false);
97 this.get('/Editor').dirty = false;
98 this.get('/Editor.save_button').el.sensitive = false;
103 xtype: GtkSource.View,
105 key_release_event : function (self, event) {
107 if (event.key.keyval == 115 && (event.key.state & Gdk.ModifierType.CONTROL_MASK ) ) {
108 print("SAVE: ctrl-S pressed");
112 // print(event.key.keyval)
122 XObject.prototype.init.call(this);
123 var description = Pango.font_description_from_string("monospace")
124 description.set_size(8000);
125 this.el.modify_font(description);
128 insert_spaces_instead_of_tabs : true,
129 load : function(str) {
131 // show the help page for the active node..
132 //this.get('/Help').show();
135 // this.get('/BottomPane').el.set_current_page(0);
136 this.el.get_buffer().set_text(str, str.length);
137 var lm = GtkSource.LanguageManager.get_default();
139 this.el.get_buffer().set_language(lm.get_language('js'));
140 var buf = this.el.get_buffer();
141 var cursor = buf.get_mark("insert");
143 buf.get_iter_at_mark(ret, cursor);
144 ret.iter.set_line(1);
145 ret.iter.set_line_offset(4);
146 buf.move_mark(cursor, ret.iter);
149 cursor = buf.get_mark("selection_bound");
151 buf.get_iter_at_mark(ret, cursor);
152 ret.iter.set_line(1);
153 ret.iter.set_line_offset(4);
154 buf.move_mark(cursor, ret.iter);
155 this.get('/Editor').dirty = false;
156 this.el.grab_focus();
157 this.get('/Editor.save_button').el.sensitive = false;
161 return this.get('/Editor.RightEditor').save();
163 show_line_numbers : true,
166 xtype: GtkSource.Buffer,
168 changed : function (self) {
170 if(this.checkSyntax()) {
171 this.get('/Editor.save_button').el.sensitive = true;
173 // print("EDITOR CHANGED");
174 this.get('/Editor').dirty = true;
176 // this.get('/LeftPanel.model').changed( str , false);
182 checkSyntax : function() {
183 var str = this.toString();
186 // print('var res = ' + str);
187 Seed.check_syntax('var res = ' + str);
192 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
193 red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC
195 print("SYNTAX ERROR IN EDITOR");
201 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
202 red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF
207 toString : function() {
211 this.el.get_start_iter(s).value;
212 this.el.get_end_iter(e).value;
214 var ret = this.el.get_text(s.iter,e.iter,true);
215 //print("TO STRING? " + ret);
228 XObject.cache['/Editor'] = Editor;