2 * as state management is a bit too complicated inside the builder
3 * it's better to seperate this into this class
5 * This class has references to all the Class instances that make up the window..
8 public class WindowState : Object
10 public MainWindow win;
22 public Xcls_WindowLeftTree left_tree;
23 public Xcls_WindowAddProp add_props;
24 public Xcls_LeftProps left_props;
25 public Xcls_ProjectSettings projectsettings;
26 public ValaProjectSettings vala_projectsettings;
27 public Xcls_RightPalete rightpalete;
28 public Editor code_editor;
29 public Xcls_WindowRooView window_rooview;
30 public Xcls_GtkView window_gladeview;
34 public About(MainWindow win)
43 // on clutter space...
44 this.projectEditInit();
55 this.webkitViewInit();
61 public void leftTreeInit()
64 this.left_tree = new Xcls_WindowLeftTree();
66 this.left_tree.main_window = _this.win;
68 this.win.tree.el.pack_start(this.left_tree.el,true, true,0);
69 this.left_tree.el.show_all();
71 this.left_tree.before_node_change.connect(() => {
72 return this.leftTreeBeforeChange();
76 this.left_tree.node_selected.connect((sel) => {
77 this.leftTreeNodeSelected(sel);
80 this.left_tree.changed.connect(() => {
81 this.window_rooview.requestRedraw();
82 this.left_tree.model.file.save();
87 public bool leftTreeBeforeChange(JsRender.Node? sel)
89 if (this.state != "codeedit") {
90 this.left_props.finish_editing();
93 if (!this.code_editor.saveContents()) {
99 public void leftTreeNodeSelected(JsRender.Node? sel)
102 print("node_selected called %s\n", (sel == null) ? "NULL" : "a value");
105 this.left_props.el.hide();
107 this.left_props.el.show();
108 this.left_props.load(this.left_tree.getActiveFile(), sel);
109 switch (this.state) {
114 this.rightpalete.clear();
117 this.rightpalete.load(this.left_tree.getActiveFile().palete(), sel.fqn());
123 this.add_props.clear();
126 this.add_props.show(this.left_tree.getActiveFile().palete(), "props", sel.fqn());
132 this.add_props.clear();
135 this.add_props.show(_this.left_tree.getActiveFile().palete(), "signals", sel.fqn());
152 public void propsListInit()
155 this.left_props =new Xcls_LeftProps();
156 this.left_props.ref();
157 this.left_props.main_window = _this;
158 this.win.props.el.pack_start(this.left_props.el,true, true,0);
159 this.left_props.el.show_all();
161 this.left_props.show_editor.connect( (file, node, type, key) => {
162 this.codeEditShow(file, node, type, key);
166 this.left_props.stop_editor.connect( () => {
167 if (this.state != "codeedit") {
171 var ret = this.code_editor.saveContents();
179 this.left_props.changed.connect(() => {
180 if (this.left_tree.getActiveFile().xtype == "Roo" ) {
181 this.window_rooview.requestRedraw();
184 this.window_gladeview.loadFile(this.left_tree.getActiveFile());
186 this.left_tree.model.updateSelected();
187 this.left_tree.model.file.save();
194 //------------- projects edit
196 public void projectEditInit()
198 this.projectsettings =new Xcls_ProjectSettings();
199 this.projectsettings.ref(); /// really?
201 this.vala_projectsettings =new ValaProjectSettings();
202 this.vala_projectsettings.ref();
203 this.vala_projectsettings.window = this;
205 ((Gtk.Container)(this.win.projecteditview.el.get_widget())).add(this.projectsettings.el);
206 //this.projectsettings.el.show_all();
208 var stage = this.win.projecteditview.el.get_stage();
209 stage.set_background_color( Clutter.Color.from_string("#000"));
211 this.projectsettings.buttonPressed.connect((btn) => {
212 if (this.left_tree.getActiveFile().xtype == "Roo" ) {
214 this.window_rooview.view.renderJS(true);
216 if (btn == "apply") {
217 this.window_rooview.view.renderJS(true);
221 // do nothing for gtk..
223 if (btn == "save" || btn == "apply") {
224 this.win.project.save();
228 this.projectEditHide();
233 // ----------- object adding
234 public void objectAddInit()
237 this.rightpalete = new Xcls_RightPalete();
238 this.rightpalete.ref(); /// really?
239 ((Gtk.Container)(this.win.objectview.el.get_widget())).add(this.rightpalete.el);
240 //this.projectsettings.el.show_all();
242 stage = _this.win.objectview.el.get_stage();
243 stage.set_background_color( Clutter.Color.from_string("#000"));
247 // ----------- properties adding list...
248 // listener uses the properties
249 public void propsAddInit()
252 this.add_props = new Xcls_WindowAddProp();
253 this.add_props.ref(); /// really?
254 ((Gtk.Container)(this.win.addpropsview.el.get_widget())).add(this.add_props.el);
255 //this.projectsettings.el.show_all();
257 var stage = _this.win.addpropsview.el.get_stage();
258 stage.set_background_color( Clutter.Color.from_string("#000"));
261 this.add_props.select.connect( (key,type,skel, etype) => {
262 this.left_props.addProp(etype, key, skel, type);
266 public void propsAddShow()
270 public void propsAddHide()
278 // ----------- Add / Edit listener
279 // listener uses the properties
280 public void listenerInit()
284 public void listenerShow()
288 public void listenerHide()
293 // -------------- codeEditor
295 public void codeEditInit()
297 this.code_editor = new Editor();
298 this.code_editor.ref(); /// really?
299 ((Gtk.Container)(this.win.codeeditview.el.get_widget())).add(this.code_editor.el);
300 //this.projectsettings.el.show_all();
302 stage = _this.win.codeeditview.el.get_stage();
303 stage.set_background_color( Clutter.Color.from_string("#000"));
306 this.code_editor.save.connect( () => {
307 this.left_tree.model.file.save();
308 this.left_tree.model.updateSelected();
313 // ----------- file view
315 public void fileViewInit()
318 this.clutterfiles = new Xcls_ClutterFiles();
319 this.clutterfiles.ref();
320 stage.add_child(this.clutterfiles.el);
321 this.clutterfiles.el.show_all();
324 this.clutterfiles.open.connect((file) => {
325 this.fileViewOpen(file);
329 public void fileViewOpen(JsRender.JsRender file)
331 this.project = file.project;
333 this.left_tree.model.loadFile(file);
335 var ctr= ((Gtk.Container)(this.win.rooview.el.get_widget()));
336 var ctr_p= ((Gtk.Container)(this.win.projecteditview.el.get_widget()));
338 if (file.xtype == "Roo" ) {
339 ctr.foreach( (w) => { ctr.remove(w); });
340 ctr_p.foreach( (w) => { ctr_p.remove(w); });
341 ctr.add(this.window_rooview.el);
342 ctr_p.add(this.projectsettings.el);
343 this.window_rooview.loadFile(file);
344 this.window_rooview.el.show_all();
345 this.projectsettings.el.show_all();
348 ctr.foreach( (w) => { ctr.remove(w); });
349 ctr_p.foreach( (w) => { ctr_p.remove(w); });
350 ctr.add(this.window_gladeview.el);
351 ctr_p.add(this.vala_projectsettings.el);
352 this.window_gladeview.loadFile(file);
353 this.window_gladeview.el.show_all();
354 this.vala_projectsettings.el.show_all();
356 print("OPEN : " + file.name);
357 this.editpane.el.set_position(_this.editpane.el.max_position);
358 this.win.setTitle(file.project.name + " : " +file.name);
364 // --------- webkit view
365 public void webkitViewInit()
367 this.window_rooview =new Xcls_WindowRooView();
368 this.window_rooview.ref();
369 ((Gtk.Container)(this.win.rooview.el.get_widget())).add(this.window_rooview.el);
370 this.window_rooview.el.show_all();
372 stage = this.win.rooview.el.get_stage();
373 stage.set_background_color( Clutter.Color.from_string("#000"));
378 public void gtkViewInit()
380 this.window_gladeview =new Xcls_GtkView();
381 this.window_gladeview.ref();