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;
31 public Xcls_DialogNewComponent new_file_dialog;
34 public WindowState(MainWindow win)
43 // on clutter space...
44 this.projectEditInit();
55 this.webkitViewInit();
65 public void leftTreeInit()
68 this.left_tree = new Xcls_WindowLeftTree();
70 this.left_tree.main_window = _this.win;
72 this.win.tree.el.pack_start(this.left_tree.el,true, true,0);
73 this.left_tree.el.show_all();
75 this.left_tree.before_node_change.connect(() => {
76 return this.leftTreeBeforeChange();
80 this.left_tree.node_selected.connect((sel) => {
81 this.leftTreeNodeSelected(sel);
84 this.left_tree.changed.connect(() => {
85 this.window_rooview.requestRedraw();
86 this.left_tree.model.file.save();
91 public bool leftTreeBeforeChange(JsRender.Node? sel)
93 if (this.state != "codeedit") {
94 this.left_props.finish_editing();
97 if (!this.code_editor.saveContents()) {
103 public void leftTreeNodeSelected(JsRender.Node? sel)
106 print("node_selected called %s\n", (sel == null) ? "NULL" : "a value");
109 this.left_props.el.hide();
111 this.left_props.el.show();
112 this.left_props.load(this.left_tree.getActiveFile(), sel);
113 switch (this.state) {
118 this.rightpalete.clear();
121 this.rightpalete.load(this.left_tree.getActiveFile().palete(), sel.fqn());
127 this.add_props.clear();
130 this.add_props.show(this.left_tree.getActiveFile().palete(), "props", sel.fqn());
136 this.add_props.clear();
139 this.add_props.show(_this.left_tree.getActiveFile().palete(), "signals", sel.fqn());
157 public void propsListInit()
160 this.left_props =new Xcls_LeftProps();
161 this.left_props.ref();
162 this.left_props.main_window = _this;
163 this.win.props.el.pack_start(this.left_props.el,true, true,0);
164 this.left_props.el.show_all();
166 this.left_props.show_editor.connect( (file, node, type, key) => {
167 this.codeEditShow(file, node, type, key);
171 this.left_props.stop_editor.connect( () => {
172 if (this.state != "codeedit") {
176 var ret = this.code_editor.saveContents();
184 this.left_props.changed.connect(() => {
185 if (this.left_tree.getActiveFile().xtype == "Roo" ) {
186 this.window_rooview.requestRedraw();
189 this.window_gladeview.loadFile(this.left_tree.getActiveFile());
191 this.left_tree.model.updateSelected();
192 this.left_tree.model.file.save();
199 //------------- projects edit
201 public void projectEditInit()
203 this.projectsettings =new Xcls_ProjectSettings();
204 this.projectsettings.ref(); /// really?
206 this.vala_projectsettings =new ValaProjectSettings();
207 this.vala_projectsettings.ref();
208 this.vala_projectsettings.window = this;
210 ((Gtk.Container)(this.win.projecteditview.el.get_widget())).add(this.projectsettings.el);
211 //this.projectsettings.el.show_all();
213 var stage = this.win.projecteditview.el.get_stage();
214 stage.set_background_color( Clutter.Color.from_string("#000"));
216 this.projectsettings.buttonPressed.connect((btn) => {
217 if (this.left_tree.getActiveFile().xtype == "Roo" ) {
219 this.window_rooview.view.renderJS(true);
221 if (btn == "apply") {
222 this.window_rooview.view.renderJS(true);
226 // do nothing for gtk..
228 if (btn == "save" || btn == "apply") {
229 this.win.project.save();
233 this.projectEditHide();
238 // ----------- object adding
239 public void objectAddInit()
242 this.rightpalete = new Xcls_RightPalete();
243 this.rightpalete.ref(); /// really?
244 ((Gtk.Container)(this.win.objectview.el.get_widget())).add(this.rightpalete.el);
245 //this.projectsettings.el.show_all();
247 stage = _this.win.objectview.el.get_stage();
248 stage.set_background_color( Clutter.Color.from_string("#000"));
252 // ----------- properties adding list...
253 // listener uses the properties
254 public void propsAddInit()
257 this.add_props = new Xcls_WindowAddProp();
258 this.add_props.ref(); /// really?
259 ((Gtk.Container)(this.win.addpropsview.el.get_widget())).add(this.add_props.el);
260 //this.projectsettings.el.show_all();
262 var stage = _this.win.addpropsview.el.get_stage();
263 stage.set_background_color( Clutter.Color.from_string("#000"));
266 this.add_props.select.connect( (key,type,skel, etype) => {
267 this.left_props.addProp(etype, key, skel, type);
271 public void propsAddShow()
275 public void propsAddHide()
283 // ----------- Add / Edit listener
284 // listener uses the properties
285 //public void listenerInit() { }
286 public void listenerShow()
290 public void listenerHide()
295 // -------------- codeEditor
297 public void codeEditInit()
299 this.code_editor = new Editor();
300 this.code_editor.ref(); /// really?
301 ((Gtk.Container)(this.win.codeeditview.el.get_widget())).add(this.code_editor.el);
302 //this.projectsettings.el.show_all();
304 stage = _this.win.codeeditview.el.get_stage();
305 stage.set_background_color( Clutter.Color.from_string("#000"));
308 this.code_editor.save.connect( () => {
309 this.left_tree.model.file.save();
310 this.left_tree.model.updateSelected();
315 // ----------- file view
317 public void fileViewInit()
320 this.clutterfiles = new Xcls_ClutterFiles();
321 this.clutterfiles.ref();
322 stage.add_child(this.clutterfiles.el);
323 this.clutterfiles.el.show_all();
326 this.clutterfiles.open.connect((file) => {
327 this.fileViewOpen(file);
331 public void fileNewInit()
333 this.new_file_dialog = new Xcls_DialogNewComponent();
334 // force it modal to the main window..
335 this.new_file_dialog.el.set_transient_for(this.el);
336 this.new_file_dialog.el.set_modal(true);
338 this.new_file_dialog.success.connect((project,file) =>
340 this.fileViewOpen(file);
346 public void fileViewOpen(JsRender.JsRender file)
348 this.win.project = file.project;
350 this.left_tree.model.loadFile(file);
352 var ctr= ((Gtk.Container)(this.win.rooview.el.get_widget()));
353 var ctr_p= ((Gtk.Container)(this.win.projecteditview.el.get_widget()));
355 if (file.xtype == "Roo" ) {
356 ctr.foreach( (w) => { ctr.remove(w); });
357 ctr_p.foreach( (w) => { ctr_p.remove(w); });
358 ctr.add(this.window_rooview.el);
359 ctr_p.add(this.projectsettings.el);
360 this.window_rooview.loadFile(file);
361 this.window_rooview.el.show_all();
362 this.projectsettings.el.show_all();
365 ctr.foreach( (w) => { ctr.remove(w); });
366 ctr_p.foreach( (w) => { ctr_p.remove(w); });
367 ctr.add(this.window_gladeview.el);
368 ctr_p.add(this.vala_projectsettings.el);
369 this.window_gladeview.loadFile(file);
370 this.window_gladeview.el.show_all();
371 this.vala_projectsettings.el.show_all();
373 print("OPEN : " + file.name);
374 this.editpane.el.set_position(_this.editpane.el.max_position);
375 this.win.setTitle(file.project.name + " : " +file.name);
381 // --------- webkit view
382 public void webkitViewInit()
384 this.window_rooview =new Xcls_WindowRooView();
385 this.window_rooview.ref();
386 ((Gtk.Container)(this.win.rooview.el.get_widget())).add(this.window_rooview.el);
387 this.window_rooview.el.show_all();
389 stage = this.win.rooview.el.get_stage();
390 stage.set_background_color( Clutter.Color.from_string("#000"));
395 public void gtkViewInit()
397 this.window_gladeview =new Xcls_GtkView();
398 this.window_gladeview.ref();