2 valac --pkg gio-2.0 --pkg posix --pkg gtk+-3.0 --pkg libnotify --pkg gtksourceview-3.0 --pkg libwnck-3.0 \
3 /tmp/Editor.vala -o /tmp/Editor
8 static int main (string[] args) {
18 public static Xcls_Editor Editor;
20 private static Xcls_Editor _this;
22 public class Xcls_Editor
25 public Xcls_save_button save_button;
26 public Xcls_RightEditor RightEditor;
27 public Xcls_view view;
28 public Xcls_buffer buffer;
31 public string activeEditor;
32 public string active_path;
35 public int pos_root_x;
36 public int pos_root_y;
41 this.el = new Gtk.Window();
46 this.activeEditor = "";
47 this.active_path = "";
52 this.el.height_request = 300;
53 this.el.title = "Application Builder - Code Editor";
54 this.el.width_request = 500;
55 var child_0 = new Xcls_VBox2();
56 this.el.add ( child_0.el );
59 this.el.delete_event.connect( (event) => {
60 if (!Editor.RightEditor.save()) {
61 // no hiding with errors.
65 _this.active_path = "";
68 this.el.configure_event.connect( (object) => {
70 this.el.get_position(out _this.pos_root_x, out _this.pos_root_y);
75 this.el.show.connect( () => {
77 _this.el.move(this.pos_root_x,this.pos_root_y);
82 // userdefined functions
84 // skip listeners - not pipe
86 // skip .activeEditor - already used
88 // skip .active_path - already used
90 // skip .dirty - already used
92 // skip .pos - already used
94 // skip .pos_root_x - already used
96 // skip .pos_root_y - already used
98 // skip height_request - already used
100 // skip id - not pipe
102 // skip title - already used
104 // skip width_request - already used
106 // skip xtype - not pipe
108 // skip |init - already used
111 if (!Editor.RightEditor.save()) {
112 // no hiding with errors.
115 _this.active_path = "";
121 // skip |xns - could not find seperator
123 // skip items - not pipe
125 // skip xvala_cls - not pipe
127 // skip xvala_xcls - not pipe
129 // skip xvala_id - not pipe
130 public class Xcls_VBox2
139 this.el = new Gtk.VBox();
143 // set gobject values
144 var child_0 = new Xcls_Toolbar3();
145 this.el.pack_start ( child_0.el , false,true );
146 var child_1 = new Xcls_RightEditor();
147 this.el.add ( child_1.el );
150 // userdefined functions
152 // skip pack - not pipe
154 // skip xtype - not pipe
156 // skip |xns - could not find seperator
158 // skip items - not pipe
160 // skip xvala_cls - not pipe
162 // skip xvala_xcls - not pipe
164 // skip xvala_id - not pipe
166 public class Xcls_Toolbar3
168 public Gtk.Toolbar el;
173 public Xcls_Toolbar3()
175 this.el = new Gtk.Toolbar();
179 // set gobject values
180 var child_0 = new Xcls_save_button();
181 this.el.add ( child_0.el );
184 // userdefined functions
186 // skip pack - not pipe
188 // skip xtype - not pipe
190 // skip |xns - could not find seperator
192 // skip items - not pipe
194 // skip xvala_cls - not pipe
196 // skip xvala_xcls - not pipe
198 // skip xvala_id - not pipe
200 public class Xcls_save_button
202 public Gtk.ToolButton el;
207 public Xcls_save_button()
209 this.el = new Gtk.ToolButton( null, "Save" );
210 _this.save_button = this;
214 // set gobject values
217 this.el.clicked.connect( () => {
218 Editor.RightEditor.save();
222 // userdefined functions
224 // skip listeners - not pipe
226 // skip id - not pipe
228 // skip label - already used
230 // skip xtype - not pipe
232 // skip |xns - could not find seperator
234 // skip xvala_cls - not pipe
236 // skip xvala_xcls - not pipe
238 // skip xvala_id - not pipe
240 public class Xcls_RightEditor
242 public Gtk.ScrolledWindow el;
247 public Xcls_RightEditor()
249 this.el = new Gtk.ScrolledWindow( null, null );
250 _this.RightEditor = this;
254 // set gobject values
255 var child_0 = new Xcls_view();
256 this.el.add ( child_0.el );
259 // userdefined functions
261 // skip id - not pipe
263 // skip pack - not pipe
265 // skip xtype - not pipe
267 print("editor.rightbutton.save");
268 if (_this.active_path.length < 1 ) {
269 print("skip - no active path");
273 var str = Editor.buffer.toString();
275 if (!Editor.buffer.checkSyntax()) {
276 print("check syntax failed");
277 //this.get('/StandardErrorDialog').show("Fix errors in code and save..");
281 // LeftPanel.model.changed( str , false);
283 _this.save_button.el.sensitive = false;
284 print("set save button grey");
288 // skip |xns - could not find seperator
290 // skip items - not pipe
292 // skip xvala_cls - not pipe
294 // skip xvala_xcls - not pipe
296 // skip xvala_id - not pipe
298 public class Xcls_view
300 public Gtk.SourceView el;
307 this.el = new Gtk.SourceView();
312 // set gobject values
313 this.el.auto_indent = true;
314 this.el.indent_width = 4;
315 this.el.insert_spaces_instead_of_tabs = true;
316 this.el.show_line_numbers = true;
317 var child_0 = new Xcls_buffer();
318 this.el.set_buffer ( child_0.el );
321 var description = Pango.FontDescription.from_string("monospace");
322 description.set_size(8000);
323 this.el.override_font(description);
326 this.el.key_release_event.connect( (event) => {
328 if (event.key.keyval == 115 && (event.key.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
329 print("SAVE: ctrl-S pressed");
333 // print(event.key.keyval)
340 // userdefined functions
342 // skip listeners - not pipe
344 // skip id - not pipe
346 // skip indent_width - already used
348 // skip pack - not pipe
350 // skip xtype - not pipe
352 // skip |auto_indent - already used
354 // skip |init - already used
356 // skip |insert_spaces_instead_of_tabs - already used
358 // skip |load - could not find seperator
361 Editor.RightEditor.save();
364 // skip |show_line_numbers - already used
366 // skip |xns - could not find seperator
368 // skip items - not pipe
370 // skip xvala_cls - not pipe
372 // skip xvala_xcls - not pipe
374 // skip xvala_id - not pipe
376 public class Xcls_buffer
378 public Gtk.SourceBuffer el;
385 this.el = new Gtk.SourceBuffer( null );
390 // set gobject values
393 this.el.changed.connect( () => {
395 if(this.checkSyntax()) {
396 Editor.save_button.sensitive = true;
398 // print("EDITOR CHANGED");
401 // this.get('/LeftPanel.model').changed( str , false);
406 // userdefined functions
408 // skip listeners - not pipe
410 // skip id - not pipe
412 // skip pack - not pipe
414 // skip xtype - not pipe
415 public bool checkSyntax() {
416 // we could try running valac... ?? but it's a bit confusing..
420 public string toString() {
424 this.el.get_start_iter(out s);
425 this.el.get_end_iter(out e);
426 var ret = this.el.get_text(s,e,true);
427 //print("TO STRING? " + ret);
431 // skip |xns - could not find seperator
433 // skip xvala_cls - not pipe
435 // skip xvala_xcls - not pipe
437 // skip xvala_id - not pipe