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();
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());
156 public void propsListInit()
159 this.left_props =new Xcls_LeftProps();
160 this.left_props.ref();
161 this.left_props.main_window = _this;
162 this.win.props.el.pack_start(this.left_props.el,true, true,0);
163 this.left_props.el.show_all();
165 this.left_props.show_editor.connect( (file, node, type, key) => {
166 this.codeEditShow(file, node, type, key);
170 this.left_props.stop_editor.connect( () => {
171 if (this.state != "codeedit") {
175 var ret = this.code_editor.saveContents();
183 this.left_props.changed.connect(() => {
184 if (this.left_tree.getActiveFile().xtype == "Roo" ) {
185 this.window_rooview.requestRedraw();
188 this.window_gladeview.loadFile(this.left_tree.getActiveFile());
190 this.left_tree.model.updateSelected();
191 this.left_tree.model.file.save();
198 //------------- projects edit
200 public void projectEditInit()
202 this.projectsettings =new Xcls_ProjectSettings();
203 this.projectsettings.ref(); /// really?
205 this.vala_projectsettings =new ValaProjectSettings();
206 this.vala_projectsettings.ref();
207 this.vala_projectsettings.window = this;
209 ((Gtk.Container)(this.win.projecteditview.el.get_widget())).add(this.projectsettings.el);
210 //this.projectsettings.el.show_all();
212 var stage = this.win.projecteditview.el.get_stage();
213 stage.set_background_color( Clutter.Color.from_string("#000"));
215 this.projectsettings.buttonPressed.connect((btn) => {
216 if (this.left_tree.getActiveFile().xtype == "Roo" ) {
218 this.window_rooview.view.renderJS(true);
220 if (btn == "apply") {
221 this.window_rooview.view.renderJS(true);
225 // do nothing for gtk..
227 if (btn == "save" || btn == "apply") {
228 this.win.project.save();
232 this.projectEditHide();
237 // ----------- object adding
238 public void objectAddInit()
241 this.rightpalete = new Xcls_RightPalete();
242 this.rightpalete.ref(); /// really?
243 ((Gtk.Container)(this.win.objectview.el.get_widget())).add(this.rightpalete.el);
244 //this.projectsettings.el.show_all();
246 stage = _this.win.objectview.el.get_stage();
247 stage.set_background_color( Clutter.Color.from_string("#000"));
251 // ----------- properties adding list...
252 // listener uses the properties
253 public void propsAddInit()
256 this.add_props = new Xcls_WindowAddProp();
257 this.add_props.ref(); /// really?
258 ((Gtk.Container)(this.win.addpropsview.el.get_widget())).add(this.add_props.el);
259 //this.projectsettings.el.show_all();
261 var stage = _this.win.addpropsview.el.get_stage();
262 stage.set_background_color( Clutter.Color.from_string("#000"));
265 this.add_props.select.connect( (key,type,skel, etype) => {
266 this.left_props.addProp(etype, key, skel, type);
270 public void propsAddShow()
274 public void propsAddHide()
282 // ----------- Add / Edit listener
283 // listener uses the properties
284 public void listenerInit()
288 public void listenerShow()
292 public void listenerHide()
297 // -------------- codeEditor
299 public void codeEditInit()
301 this.code_editor = new Editor();
302 this.code_editor.ref(); /// really?
303 ((Gtk.Container)(this.win.codeeditview.el.get_widget())).add(this.code_editor.el);
304 //this.projectsettings.el.show_all();
306 stage = _this.win.codeeditview.el.get_stage();
307 stage.set_background_color( Clutter.Color.from_string("#000"));
310 this.code_editor.save.connect( () => {
311 this.left_tree.model.file.save();
312 this.left_tree.model.updateSelected();
317 // ----------- file view
319 public void fileViewInit()
322 this.clutterfiles = new Xcls_ClutterFiles();
323 this.clutterfiles.ref();
324 stage.add_child(this.clutterfiles.el);
325 this.clutterfiles.el.show_all();
328 this.clutterfiles.open.connect((file) => {
329 this.fileViewOpen(file);
333 public void fileNewInit()
335 this.new_file_dialog = new Xcls_DialogNewComponent();
336 // force it modal to the main window..
337 this.new_file_dialog.el.set_transient_for(this.el);
338 this.new_file_dialog.el.set_modal(true);
340 this.new_file_dialog.success.connect((project,file) =>
342 this.fileViewOpen(file);
348 public void fileViewOpen(JsRender.JsRender file)
350 this.win.project = file.project;
352 this.left_tree.model.loadFile(file);
354 var ctr= ((Gtk.Container)(this.win.rooview.el.get_widget()));
355 var ctr_p= ((Gtk.Container)(this.win.projecteditview.el.get_widget()));
357 if (file.xtype == "Roo" ) {
358 ctr.foreach( (w) => { ctr.remove(w); });
359 ctr_p.foreach( (w) => { ctr_p.remove(w); });
360 ctr.add(this.window_rooview.el);
361 ctr_p.add(this.projectsettings.el);
362 this.window_rooview.loadFile(file);
363 this.window_rooview.el.show_all();
364 this.projectsettings.el.show_all();
367 ctr.foreach( (w) => { ctr.remove(w); });
368 ctr_p.foreach( (w) => { ctr_p.remove(w); });
369 ctr.add(this.window_gladeview.el);
370 ctr_p.add(this.vala_projectsettings.el);
371 this.window_gladeview.loadFile(file);
372 this.window_gladeview.el.show_all();
373 this.vala_projectsettings.el.show_all();
375 print("OPEN : " + file.name);
376 this.editpane.el.set_position(_this.editpane.el.max_position);
377 this.win.setTitle(file.project.name + " : " +file.name);
383 // --------- webkit view
384 public void webkitViewInit()
386 this.window_rooview =new Xcls_WindowRooView();
387 this.window_rooview.ref();
388 ((Gtk.Container)(this.win.rooview.el.get_widget())).add(this.window_rooview.el);
389 this.window_rooview.el.show_all();
391 stage = this.win.rooview.el.get_stage();
392 stage.set_background_color( Clutter.Color.from_string("#000"));
397 public void gtkViewInit()
399 this.window_gladeview =new Xcls_GtkView();
400 this.window_gladeview.ref();