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;
23 public Xcls_WindowLeftTree left_tree;
24 public Xcls_WindowAddProp add_props;
25 public Xcls_LeftProps left_props;
26 public Xcls_ProjectSettings projectsettings;
27 public ValaProjectSettings vala_projectsettings;
28 public Xcls_RightPalete rightpalete;
29 public Editor code_editor;
30 public Xcls_WindowRooView window_rooview;
31 public Xcls_GtkView window_gladeview;
32 public Xcls_DialogNewComponent new_file_dialog;
35 public WindowState(MainWindow win)
44 // on clutter space...
45 this.projectEditInit();
56 this.webkitViewInit();
66 public void leftTreeInit()
69 this.left_tree = new Xcls_WindowLeftTree();
71 this.left_tree.main_window = _this.win;
73 this.win.tree.el.pack_start(this.left_tree.el,true, true,0);
74 this.left_tree.el.show_all();
76 this.left_tree.before_node_change.connect(() => {
77 return this.leftTreeBeforeChange();
81 this.left_tree.node_selected.connect((sel) => {
82 this.leftTreeNodeSelected(sel);
85 this.left_tree.changed.connect(() => {
86 this.window_rooview.requestRedraw();
87 this.left_tree.model.file.save();
92 public bool leftTreeBeforeChange(JsRender.Node? sel)
94 if (this.state != "codeedit") {
95 this.left_props.finish_editing();
98 if (!this.code_editor.saveContents()) {
104 public void leftTreeNodeSelected(JsRender.Node? sel)
107 print("node_selected called %s\n", (sel == null) ? "NULL" : "a value");
110 this.left_props.el.hide();
112 this.left_props.el.show();
113 this.left_props.load(this.left_tree.getActiveFile(), sel);
114 switch (this.state) {
119 this.rightpalete.clear();
122 this.rightpalete.load(this.left_tree.getActiveFile().palete(), sel.fqn());
128 this.add_props.clear();
131 this.add_props.show(this.left_tree.getActiveFile().palete(), "props", sel.fqn());
137 this.add_props.clear();
140 this.add_props.show(_this.left_tree.getActiveFile().palete(), "signals", sel.fqn());
158 public void propsListInit()
161 this.left_props =new Xcls_LeftProps();
162 this.left_props.ref();
163 this.left_props.main_window = _this;
164 this.win.props.el.pack_start(this.left_props.el,true, true,0);
165 this.left_props.el.show_all();
167 this.left_props.show_editor.connect( (file, node, type, key) => {
168 this.codeEditShow(file, node, type, key);
172 this.left_props.stop_editor.connect( () => {
173 if (this.state != "codeedit") {
177 var ret = this.code_editor.saveContents();
185 this.left_props.changed.connect(() => {
186 if (this.left_tree.getActiveFile().xtype == "Roo" ) {
187 this.window_rooview.requestRedraw();
190 this.window_gladeview.loadFile(this.left_tree.getActiveFile());
192 this.left_tree.model.updateSelected();
193 this.left_tree.model.file.save();
200 //------------- projects edit
202 public void projectEditInit()
204 this.projectsettings =new Xcls_ProjectSettings();
205 this.projectsettings.ref(); /// really?
207 this.vala_projectsettings =new ValaProjectSettings();
208 this.vala_projectsettings.ref();
209 this.vala_projectsettings.window = this;
211 ((Gtk.Container)(this.win.projecteditview.el.get_widget())).add(this.projectsettings.el);
212 //this.projectsettings.el.show_all();
214 var stage = this.win.projecteditview.el.get_stage();
215 stage.set_background_color( Clutter.Color.from_string("#000"));
217 this.projectsettings.buttonPressed.connect((btn) => {
218 if (this.left_tree.getActiveFile().xtype == "Roo" ) {
220 this.window_rooview.view.renderJS(true);
222 if (btn == "apply") {
223 this.window_rooview.view.renderJS(true);
227 // do nothing for gtk..
229 if (btn == "save" || btn == "apply") {
230 this.win.project.save();
234 this.projectEditHide();
239 // ----------- object adding
240 public void objectAddInit()
243 this.rightpalete = new Xcls_RightPalete();
244 this.rightpalete.ref(); /// really?
245 ((Gtk.Container)(this.win.objectview.el.get_widget())).add(this.rightpalete.el);
246 //this.projectsettings.el.show_all();
248 stage = _this.win.objectview.el.get_stage();
249 stage.set_background_color( Clutter.Color.from_string("#000"));
253 // ----------- properties adding list...
254 // listener uses the properties
255 public void propsAddInit()
258 this.add_props = new Xcls_WindowAddProp();
259 this.add_props.ref(); /// really?
260 ((Gtk.Container)(this.win.addpropsview.el.get_widget())).add(this.add_props.el);
261 //this.projectsettings.el.show_all();
263 var stage = _this.win.addpropsview.el.get_stage();
264 stage.set_background_color( Clutter.Color.from_string("#000"));
267 this.add_props.select.connect( (key,type,skel, etype) => {
268 this.left_props.addProp(etype, key, skel, type);
272 public void propsAddShow()
276 public void propsAddHide()
284 // ----------- Add / Edit listener
285 // listener uses the properties
286 //public void listenerInit() { }
287 public void listenerShow()
291 public void listenerHide()
296 // -------------- codeEditor
298 public void codeEditInit()
300 this.code_editor = new Editor();
301 this.code_editor.ref(); /// really?
302 ((Gtk.Container)(this.win.codeeditview.el.get_widget())).add(this.code_editor.el);
303 //this.projectsettings.el.show_all();
305 stage = _this.win.codeeditview.el.get_stage();
306 stage.set_background_color( Clutter.Color.from_string("#000"));
309 this.code_editor.save.connect( () => {
310 this.left_tree.model.file.save();
311 this.left_tree.model.updateSelected();
316 // ----------- file view
318 public void fileViewInit()
320 stage = _this.rooview.el.get_stage(); \\ seems odd...
321 this.clutterfiles = new Xcls_ClutterFiles();
322 this.clutterfiles.ref();
323 stage.add_child(this.clutterfiles.el);
324 this.clutterfiles.el.show_all();
327 this.clutterfiles.open.connect((file) => {
328 this.fileViewOpen(file);
332 public void fileNewInit()
334 this.new_file_dialog = new Xcls_DialogNewComponent();
335 // force it modal to the main window..
336 this.new_file_dialog.el.set_transient_for(this.el);
337 this.new_file_dialog.el.set_modal(true);
339 this.new_file_dialog.success.connect((project,file) =>
341 this.fileViewOpen(file);
347 public void fileViewOpen(JsRender.JsRender file)
349 this.win.project = file.project;
351 this.left_tree.model.loadFile(file);
353 var ctr= ((Gtk.Container)(this.win.rooview.el.get_widget()));
354 var ctr_p= ((Gtk.Container)(this.win.projecteditview.el.get_widget()));
356 if (file.xtype == "Roo" ) {
357 ctr.foreach( (w) => { ctr.remove(w); });
358 ctr_p.foreach( (w) => { ctr_p.remove(w); });
359 ctr.add(this.window_rooview.el);
360 ctr_p.add(this.projectsettings.el);
361 this.window_rooview.loadFile(file);
362 this.window_rooview.el.show_all();
363 this.projectsettings.el.show_all();
366 ctr.foreach( (w) => { ctr.remove(w); });
367 ctr_p.foreach( (w) => { ctr_p.remove(w); });
368 ctr.add(this.window_gladeview.el);
369 ctr_p.add(this.vala_projectsettings.el);
370 this.window_gladeview.loadFile(file);
371 this.window_gladeview.el.show_all();
372 this.vala_projectsettings.el.show_all();
374 print("OPEN : " + file.name);
375 this.editpane.el.set_position(_this.editpane.el.max_position);
376 this.win.setTitle(file.project.name + " : " +file.name);
382 // --------- webkit view
383 public void webkitViewInit()
385 this.window_rooview =new Xcls_WindowRooView();
386 this.window_rooview.ref();
387 ((Gtk.Container)(this.win.rooview.el.get_widget())).add(this.window_rooview.el);
388 this.window_rooview.el.show_all();
390 stage = this.win.rooview.el.get_stage();
391 stage.set_background_color( Clutter.Color.from_string("#000"));
396 public void gtkViewInit()
398 this.window_gladeview =new Xcls_GtkView();
399 this.window_gladeview.ref();
402 // -- buttons show hide.....
404 public void buttonsShowHide()
406 // basically hide everything, then show the relivant..
407 switch (this.state) {
409 case State.PREVIEW: // this is the default state when working...
411 this.backbutton.el.hide();
412 this.projectbutton.el.show();
413 this.projecteditbutton.el.show();
414 this.editfilebutton.el.show();