From 35cbda1fec71d9e15d1d7c5a66db876794a4e457 Mon Sep 17 00:00:00 2001 From: Alan Date: Fri, 13 May 2022 13:09:37 +0800 Subject: [PATCH] Fix #7214 - move edit code into popover --- .gitignore | 6 + src/Builder4/Editor.bjs | 662 +++++++++++-- src/Builder4/Editor.vala | 30 +- src/Builder4/MainWindow.bjs | 1367 +++++++++++++++++++-------- src/Builder4/MainWindow.vala | 20 +- src/Builder4/PopoverAddObject.bjs | 256 +++++ src/Builder4/PopoverAddObject.vala | 342 +++++++ src/Builder4/PopoverAddProp.bjs | 224 +++++ src/Builder4/PopoverAddProp.vala | 316 +++++++ src/Builder4/PopoverEditor.bjs | 81 ++ src/Builder4/PopoverEditor.vala | 89 ++ src/Builder4/PopoverFileDetails.bjs | 740 ++++++++++++--- src/Builder4/PopoverProperty.bjs | 328 +++++-- src/Builder4/WindowAddProp.bjs | 175 +++- src/Builder4/WindowRightPalete.bjs | 229 ++++- src/Builder4/WindowState.vala | 428 +++------ src/Builder4/config1.builder | 9 +- src/Makefile.am | 5 +- 18 files changed, 4212 insertions(+), 1095 deletions(-) create mode 100644 src/Builder4/PopoverAddObject.bjs create mode 100644 src/Builder4/PopoverAddObject.vala create mode 100644 src/Builder4/PopoverAddProp.bjs create mode 100644 src/Builder4/PopoverAddProp.vala create mode 100644 src/Builder4/PopoverEditor.bjs create mode 100644 src/Builder4/PopoverEditor.vala diff --git a/.gitignore b/.gitignore index 1ff0cd354..217a60bb6 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,12 @@ src/roobuilder src/*.stamp src/*.stamp-t tests/*.c +src/ccode/*.c +src/ccode/*.o +src/codegen/*.c +src/codegen/*.o + + Makecache Makefile diff --git a/src/Builder4/Editor.bjs b/src/Builder4/Editor.bjs index f10439bbb..7562ad0ca 100644 --- a/src/Builder4/Editor.bjs +++ b/src/Builder4/Editor.bjs @@ -1,126 +1,640 @@ { - "name" : "Editor", - "parent" : "", - "title" : "", - "path" : "/home/alan/gitlive/roobuilder/src/Builder4/Editor.bjs", - "permname" : "", - "modOrder" : "", "build_module" : "builder", "items" : [ { + "# JsRender.JsRender file" : "null", + "# JsRender.Node node" : "null", "# Xcls_MainWindow window" : "null", - "| bool saveContents" : " () {\n \n \n if (_this.file == null) {\n return true;\n }\n \n \n \n \n \n var str = _this.buffer.toString();\n \n _this.buffer.checkSyntax();\n \n \n \n // LeftPanel.model.changed( str , false);\n _this.dirty = false;\n _this.save_button.el.sensitive = false;\n \n // find the text for the node..\n if (_this.file.xtype != \"PlainFile\") {\n if (ptype == \"listener\") {\n this.node.listeners.set(key,str);\n \n } else {\n this.node.props.set(key,str);\n }\n } else {\n _this.file.setSource( str );\n }\n \n // call the signal..\n this.save();\n \n return true;\n\n} ", - "# string activeEditor" : "\"\"", - "| void scroll_to_line" : "(int line) {\n\n\tGLib.Timeout.add(500, () => {\n \n\t\tvar buf = this.view.el.get_buffer();\n\n\t\tvar sbuf = (Gtk.SourceBuffer) buf;\n\n\n\t\tGtk.TextIter iter; \n\t\tsbuf.get_iter_at_line(out iter, line);\n\t\tthis.view.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);\n\t\treturn false;\n\t}); \n}\n", + "# bool dirty" : false, + "# bool pos" : false, "# int pos_root_x" : "", "# int pos_root_y" : "", - "# string ptype" : "\"\"", - "bool hexpand" : true, - "| int search" : "(string txt) {\n\n\tvar s = new Gtk.SourceSearchSettings();\n\t\n\tthis.searchcontext = new Gtk.SourceSearchContext(this.buffer.el,s);\n\tthis.searchcontext .set_highlight(true);\n\ts.set_search_text(txt);\n\tGtk.TextIter beg, st,en;\n\t \n\tthis.buffer.el.get_start_iter(out beg);\n\tthis.searchcontext.forward(beg, out st, out en);\n\tthis.last_search_end = 0;\n\t\n\treturn this.searchcontext.get_occurrences_count();\n\n \n \n\n}\n", - "int last_search_end" : 0, + "# string activeEditor" : "\"\"", "# string key" : "\"\"", - "* pack" : "add", - "xtype" : "Box", - "Gtk.SourceSearchContext searchcontext" : "null", - "| void show" : "(JsRender.JsRender file, JsRender.Node? node, string ptype, string key)\n{\n this.file = file; \n this.ptype = \"\";\n this.key = \"\";\n this.node = null;\n\tthis.searchcontext = null;\n \n if (file.xtype != \"PlainFile\") {\n \n this.ptype = ptype;\n this.key = key;\n this.node = node;\n string val = \"\";\n // find the text for the node..\n if (ptype == \"listener\") {\n val = node.listeners.get(key);\n \n } else {\n val = node.props.get(key);\n }\n this.view.load(val);\n this.key_edit.el.show();\n this.key_edit.el.text = key; \n \n } else {\n this.view.load( file.toSource() );\n this.key_edit.el.hide();\n }\n\n \n}", - "# JsRender.JsRender file" : "null", - "# bool pos" : false, - "string id" : "Editor", - "# bool dirty" : false, + "# string ptype" : "\"\"", + "$ homogeneous" : false, "$ xns" : "Gtk", - "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", + "* pack" : "add", "@ void save" : "()", - "$ homogeneous" : false, - "| void forwardSearch" : "(bool change_focus) {\n\n\tif (this.searchcontext == null) {\n\t\treturn;\n\t}\n\t\n\tGtk.TextIter beg, st,en;\n\t \n\tthis.buffer.el.get_iter_at_offset(out beg, this.last_search_end);\n\tif (!this.searchcontext.forward(beg, out st, out en)) {\n\t\n\t\tthis.last_search_end = 0;\n\t} else {\n\t\tthis.last_search_end = en.get_offset();\n\t\tif (change_focus) {\n\t\t\tthis.view.el.grab_focus();\n\t\t}\n\t\tthis.buffer.el.place_cursor(st);\n\t\tthis.view.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f);\n\t}\n\n}\n", - "# JsRender.Node node" : "null", + "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", + "Gtk.SourceSearchContext searchcontext" : "null", + "bool hexpand" : true, + "int last_search_end" : 0, "items" : [ { - "* pack" : "pack_start,false,true", - "xtype" : "Box", + "$ homogeneous" : false, "$ xns" : "Gtk", + "* pack" : "pack_start,false,true", "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL", - "$ homogeneous" : false, "items" : [ { + "$ xns" : "Gtk", + "* pack" : "pack_start,false,false", + "id" : "save_button", + "label" : "Save", "listeners" : { - "clicked" : " () => { \n _this.saveContents();\n}\n " + "clicked" : [ + " () => { ", + " _this.saveContents();", + "}", + " " + ] }, - "label" : "Save", - "id" : "save_button", - "* pack" : "pack_start,false,false", - "xtype" : "Button", - "$ xns" : "Gtk" + "xtype" : "Button" }, { - "id" : "key_edit", + "$ xns" : "Gtk", "* pack" : "pack_start,true,true", - "xtype" : "Entry", + "bool editable" : false, + "id" : "key_edit", "int width_request" : 100, - "$ xns" : "Gtk" + "xtype" : "Entry" }, { - "listeners" : { - "change_value" : "(st, val ) => {\n\t \n\t var description = Pango.FontDescription.from_string(\"monospace\");\n\t print(\"resize to %d\", (int)val*1000);\n description.set_size((int)val*1000);\n _this.view.el.override_font(description);\n return false;\n}" - }, + "$ xns" : "Gtk", "* ctor" : "new Gtk.HScale.with_range (6, 30, 1)", - "* init" : "{\n\tthis.el.set_range(6,30);\n\tthis.el.set_value(8);\n}\n", + "* init" : [ + "{", + "\tthis.el.set_range(6,30);", + "\tthis.el.set_value(8);", + "}", + "" + ], "* pack" : "pack_end,true,true", - "int digits" : 0, - "xtype" : "HScale", + "bool draw_value" : true, "bool has_origin" : true, "bool sensitive" : true, - "$ xns" : "Gtk", - "bool draw_value" : true + "int digits" : 0, + "listeners" : { + "change_value" : [ + "(st, val ) => {", + "\t ", + "\t var description = Pango.FontDescription.from_string(\"monospace\");", + "\t print(\"resize to %d\", (int)val*1000);", + " description.set_size((int)val*1000);", + " _this.view.el.override_font(description);", + " return false;", + "}" + ] + }, + "xtype" : "HScale" } - ] + ], + "xtype" : "Box" }, { - "id" : "RightEditor", + "$ xns" : "Gtk", "* init" : "this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);", - "xtype" : "ScrolledWindow", "* pack" : "pack_end,true,true", - "$ xns" : "Gtk", + "id" : "RightEditor", "items" : [ { - "listeners" : { - "key_release_event" : " (event) => {\n \n if (event.keyval == 115 && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {\n print(\"SAVE: ctrl-S pressed\");\n _this.saveContents();\n return false;\n }\n // print(event.key.keyval)\n \n return false;\n\n} \n\n " - }, - "gboolean show_line_marks" : true, - "id" : "view", - "* init" : " \n\n\t\tvar description = Pango.FontDescription.from_string(\"monospace\");\n\t\tdescription.set_size(8000);\n\n\t\t this.el.override_font(description);\n\n\ttry { \n\t\tthis.el.completion.add_provider(new Palete.CompletionProvider(_this));\n } catch (GLib.Error e) {}\n \n\tthis.el.completion.unblock_interactive();\n\tthis.el.completion.select_on_show\t\t\t= true; // select\n\tthis.el.completion.show_headers\t\t\t= false;\n\tthis.el.completion.remember_info_visibility\t\t= true;\n \n \n var attrs = new Gtk.SourceMarkAttributes();\n var pink = Gdk.RGBA();\n pink.parse ( \"pink\");\n attrs.set_background ( pink);\n attrs.set_icon_name ( \"process-stop\"); \n attrs.query_tooltip_text.connect(( mark) => {\n //print(\"tooltip query? %s\\n\", mark.name);\n return mark.name;\n });\n \n this.el.set_mark_attributes (\"ERR\", attrs, 1);\n \n var wattrs = new Gtk.SourceMarkAttributes();\n var blue = Gdk.RGBA();\n blue.parse ( \"#ABF4EB\");\n wattrs.set_background ( blue);\n wattrs.set_icon_name ( \"process-stop\"); \n wattrs.query_tooltip_text.connect(( mark) => {\n //print(\"tooltip query? %s\\n\", mark.name);\n return mark.name;\n });\n \n this.el.set_mark_attributes (\"WARN\", wattrs, 1);\n \n \n \n var dattrs = new Gtk.SourceMarkAttributes();\n var purple = Gdk.RGBA();\n purple.parse ( \"#EEA9FF\");\n dattrs.set_background ( purple);\n dattrs.set_icon_name ( \"process-stop\"); \n dattrs.query_tooltip_text.connect(( mark) => {\n //print(\"tooltip query? %s\\n\", mark.name);\n return mark.name;\n });\n \n this.el.set_mark_attributes (\"DEPR\", dattrs, 1);\n \n ", - "uint tab_width" : 4, "$ Gtk.SourceDrawSpacesFlags draw_spaces" : "Gtk.SourceDrawSpacesFlags.LEADING + Gtk.SourceDrawSpacesFlags.TRAILING + Gtk.SourceDrawSpacesFlags.TAB + Gtk.SourceDrawSpacesFlags.SPACE", - "* pack" : "add", - "xtype" : "SourceView", - "gboolean highlight_current_line" : true, "$ gboolean auto_indent" : true, + "$ show_line_numbers" : true, "$ xns" : "Gtk", - "| void load" : " (string str) {\n\n// show the help page for the active node..\n //this.get('/Help').show();\n\n\n // this.get('/BottomPane').el.set_current_page(0);\n var buf = (Gtk.SourceBuffer)this.el.get_buffer();\n buf.set_text(str, str.length);\n buf.set_undo_manager(null);\n \n var lm = Gtk.SourceLanguageManager.get_default();\n var lang = \"vala\";\n if (_this.file != null) {\n lang = _this.file.language;\n }\n print(\"lang=%s, content_type = %s\\n\", lang, _this.file.content_type);\n var lg = _this.file.content_type.length > 0 ?\n lm.guess_language(_this.file.path, _this.file.content_type) :\n lm.get_language(lang);\n \n \n ((Gtk.SourceBuffer)(this.el.get_buffer())) .set_language(lg); \n\n this.el.insert_spaces_instead_of_tabs = true;\n if (lg != null) {\n\t\tprint(\"sourcelanguage = %s\\n\", lg.name);\n\t\tif (lg.name == \"Vala\") {\n\t\t this.el.insert_spaces_instead_of_tabs = false;\n\t\t}\n }\n _this.dirty = false;\n this.el.grab_focus();\n _this.save_button.el.sensitive = false;\n}", + "* init" : [ + " ", + "", + "\t\tvar description = Pango.FontDescription.from_string(\"monospace\");", + "\t\tdescription.set_size(8000);", + "", + "\t\t this.el.override_font(description);", + "", + "\ttry { ", + "\t\tthis.el.completion.add_provider(new Palete.CompletionProvider(_this));", + " } catch (GLib.Error e) {}", + " ", + "\tthis.el.completion.unblock_interactive();", + "\tthis.el.completion.select_on_show\t\t\t= true; // select", + "\tthis.el.completion.show_headers\t\t\t= false;", + "\tthis.el.completion.remember_info_visibility\t\t= true;", + " ", + " ", + " var attrs = new Gtk.SourceMarkAttributes();", + " var pink = Gdk.RGBA();", + " pink.parse ( \"pink\");", + " attrs.set_background ( pink);", + " attrs.set_icon_name ( \"process-stop\"); ", + " attrs.query_tooltip_text.connect(( mark) => {", + " //print(\"tooltip query? %s\\n\", mark.name);", + " return mark.name;", + " });", + " ", + " this.el.set_mark_attributes (\"ERR\", attrs, 1);", + " ", + " var wattrs = new Gtk.SourceMarkAttributes();", + " var blue = Gdk.RGBA();", + " blue.parse ( \"#ABF4EB\");", + " wattrs.set_background ( blue);", + " wattrs.set_icon_name ( \"process-stop\"); ", + " wattrs.query_tooltip_text.connect(( mark) => {", + " //print(\"tooltip query? %s\\n\", mark.name);", + " return mark.name;", + " });", + " ", + " this.el.set_mark_attributes (\"WARN\", wattrs, 1);", + " ", + " ", + " ", + " var dattrs = new Gtk.SourceMarkAttributes();", + " var purple = Gdk.RGBA();", + " purple.parse ( \"#EEA9FF\");", + " dattrs.set_background ( purple);", + " dattrs.set_icon_name ( \"process-stop\"); ", + " dattrs.query_tooltip_text.connect(( mark) => {", + " //print(\"tooltip query? %s\\n\", mark.name);", + " return mark.name;", + " });", + " ", + " this.el.set_mark_attributes (\"DEPR\", dattrs, 1);", + " ", + " " + ], + "* pack" : "add", "bool insert_spaces_instead_of_tabs" : true, + "gboolean highlight_current_line" : true, + "gboolean show_line_marks" : true, + "id" : "view", "indent_width" : 4, - "$ show_line_numbers" : true, "items" : [ { - "listeners" : { - "changed" : " () => {\n // check syntax??\n // ??needed..??\n _this.save_button.el.sensitive = true;\n print(\"EDITOR CHANGED\");\n this.checkSyntax();\n \n _this.dirty = true;\n\n // this.get('/LeftPanel.model').changed( str , false);\n return ;\n}\n\n \n" - }, + "$ xns" : "Gtk", + "* pack" : "set_buffer", "bool check_queued" : false, - "int error_line" : "-1", + "bool check_running" : false, "id" : "buffer", - "| bool highlightErrors" : "( Gee.HashMap validate_res) {\n \n this.error_line = validate_res.size;\n\n if (this.error_line < 1) {\n return true;\n }\n var tlines = this.el.get_line_count ();\n Gtk.TextIter iter;\n var valiter = validate_res.map_iterator();\n while (valiter.next()) {\n \n // print(\"get inter\\n\");\n var eline = valiter.get_key();\n if (eline > tlines) {\n continue;\n }\n this.el.get_iter_at_line( out iter, eline);\n //print(\"mark line\\n\");\n this.el.create_source_mark(valiter.get_value(), \"ERR\", iter);\n } \n return false;\n }", - "| string toString" : " () {\n \n Gtk.TextIter s;\n Gtk.TextIter e;\n this.el.get_start_iter(out s);\n this.el.get_end_iter(out e);\n var ret = this.el.get_text(s,e,true);\n //print(\"TO STRING? \" + ret);\n return ret;\n}\n ", - "| bool checkSyntax" : " () {\n \n if (this.check_running) {\n print(\"Check is running\\n\");\n if (this.check_queued) { \n print(\"Check is already queued\");\n return true;\n }\n this.check_queued = true;\n print(\"Adding queued Check \");\n GLib.Timeout.add_seconds(1, () => {\n this.check_queued = false;\n \n this.checkSyntax();\n return false;\n });\n \n\n return true;\n }\n var str = this.toString();\n \n // needed???\n if (this.error_line > 0) {\n Gtk.TextIter start;\n Gtk.TextIter end; \n this.el.get_bounds (out start, out end);\n\n this.el.remove_source_marks (start, end, null);\n }\n if (str.length < 1) {\n print(\"checkSyntax - empty string?\\n\");\n return true;\n }\n \n if (_this.file.xtype == \"PlainFile\") {\n \n // assume it's gtk...\n this.check_running = true;\n \n if (!_this.window.windowstate.valasource.checkPlainFileSpawn(\n\t _this.file,\n\t str\n\t )) {\n this.check_running = false;\n }\n\t\n return true;\n \n }\n if (_this.file == null) {\n return true;\n }\n var p = _this.file.project.palete;\n \n\n \n this.check_running = true;\n \n \n if (_this.file.language == \"js\") {\n this.check_running = false;\n print(\"calling validate javascript\\n\"); \n Gee.HashMap errors;\n p.javascriptHasErrors(\n \t\t_this.window.windowstate,\n str, \n _this.key, \n _this.ptype,\n _this.file,\n \n out errors\n );\n return this.highlightErrors(errors); \n \n }\n \n \n print(\"calling validate vala\\n\"); \n // clear the buttons.\n \n \n if (! _this.window.windowstate.valasource.checkFileWithNodePropChange(\n _this.file,\n _this.node,\n _this.key, \n _this.ptype,\n str\n )) {\n this.check_running = false;\n } \n \n \n \n //print(\"done mark line\\n\");\n \n return true; // at present allow saving - even if it's invalid..\n}\n", - "* pack" : "set_buffer", + "int error_line" : "-1", + "listeners" : { + "changed" : [ + " () => {", + " // check syntax??", + " // ??needed..??", + " _this.save_button.el.sensitive = true;", + " print(\"EDITOR CHANGED\");", + " this.checkSyntax();", + " ", + " _this.dirty = true;", + "", + " // this.get('/LeftPanel.model').changed( str , false);", + " return ;", + "}", + "", + " ", + "" + ] + }, "xtype" : "SourceBuffer", - "bool check_running" : false, - "$ xns" : "Gtk", - "| bool highlightErrorsJson" : "(string type, Json.Object obj) {\n Gtk.TextIter start;\n Gtk.TextIter end; \n this.el.get_bounds (out start, out end);\n \n this.el.remove_source_marks (start, end, type);\n \n \n // we should highlight other types of errors..\n \n if (!obj.has_member(type)) {\n print(\"Return has no errors\\n\");\n return true;\n }\n \n if (_this.window.windowstate.state != WindowState.State.CODEONLY && \n _this.window.windowstate.state != WindowState.State.CODE\n ) {\n return true;\n } \n \n \n var err = obj.get_object_member(type);\n \n \n if (_this.file == null) {\n return true;\n \n }\n var valafn = _this.file.path;\n \n if (_this.file.xtype != \"PlainFile\") {\n\n\n \n \n valafn = \"\";\n try { \n var regex = new Regex(\"\\\\.bjs$\");\n // should not happen\n \n \n valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , \".vala\");\n } catch (GLib.RegexError e) {\n return true;\n } \n\n\n\n }\n if (!err.has_member(valafn)) {\n print(\"File path has no errors\\n\");\n return true;\n }\n\n var lines = err.get_object_member(valafn);\n \n var offset = 1;\n if (obj.has_member(\"line_offset\")) {\n offset = (int)obj.get_int_member(\"line_offset\") + 1;\n }\n \n\n \n \n var tlines = this.el.get_line_count () +1;\n \n lines.foreach_member((obj, line, node) => {\n \n Gtk.TextIter iter;\n // print(\"get inter\\n\");\n var eline = int.parse(line) - offset;\n print(\"GOT ERROR on line %s -- converted to %d\\n\", line,eline);\n \n \n if (eline > tlines || eline < 0) {\n return;\n }\n this.el.get_iter_at_line( out iter, eline);\n //print(\"mark line\\n\");\n var msg = \"Line: %d\".printf(eline+1);\n var ar = lines.get_array_member(line);\n for (var i = 0 ; i < ar.get_length(); i++) {\n\t\t msg += (msg.length > 0) ? \"\\n\" : \"\";\n\t\t msg += ar.get_string_element(i);\n\t }\n \n \n this.el.create_source_mark(msg, type, iter);\n } );\n return false;\n \n\n\n\n\n}\n" + "| bool checkSyntax" : [ + " () {", + " ", + " if (this.check_running) {", + " print(\"Check is running\\n\");", + " if (this.check_queued) { ", + " print(\"Check is already queued\");", + " return true;", + " }", + " this.check_queued = true;", + " print(\"Adding queued Check \");", + " GLib.Timeout.add_seconds(1, () => {", + " this.check_queued = false;", + " ", + " this.checkSyntax();", + " return false;", + " });", + " ", + "", + " return true;", + " }", + " var str = this.toString();", + " ", + " // needed???", + " if (this.error_line > 0) {", + " Gtk.TextIter start;", + " Gtk.TextIter end; ", + " this.el.get_bounds (out start, out end);", + "", + " this.el.remove_source_marks (start, end, null);", + " }", + " if (str.length < 1) {", + " print(\"checkSyntax - empty string?\\n\");", + " return true;", + " }", + " ", + " if (_this.file.xtype == \"PlainFile\") {", + " ", + " // assume it's gtk...", + " this.check_running = true;", + " ", + " if (!_this.window.windowstate.valasource.checkPlainFileSpawn(", + "\t _this.file,", + "\t str", + "\t )) {", + " this.check_running = false;", + " }", + "\t", + " return true;", + " ", + " }", + " if (_this.file == null) {", + " return true;", + " }", + " var p = _this.file.project.palete;", + " ", + "", + " ", + " this.check_running = true;", + " ", + " ", + " if (_this.file.language == \"js\") {", + " this.check_running = false;", + " print(\"calling validate javascript\\n\"); ", + " Gee.HashMap errors;", + " p.javascriptHasErrors(", + " \t\t_this.window.windowstate,", + " str, ", + " _this.key, ", + " _this.ptype,", + " _this.file,", + " ", + " out errors", + " );", + " return this.highlightErrors(errors); ", + " ", + " }", + " ", + " ", + " print(\"calling validate vala\\n\"); ", + " // clear the buttons.", + " ", + " ", + " if (! _this.window.windowstate.valasource.checkFileWithNodePropChange(", + " _this.file,", + " _this.node,", + " _this.key, ", + " _this.ptype,", + " str", + " )) {", + " this.check_running = false;", + " } ", + " ", + " ", + " ", + " //print(\"done mark line\\n\");", + " ", + " return true; // at present allow saving - even if it's invalid..", + "}", + "" + ], + "| string toString" : [ + " () {", + " ", + " Gtk.TextIter s;", + " Gtk.TextIter e;", + " this.el.get_start_iter(out s);", + " this.el.get_end_iter(out e);", + " var ret = this.el.get_text(s,e,true);", + " //print(\"TO STRING? \" + ret);", + " return ret;", + "}", + " " + ], + "| bool highlightErrors" : [ + "( Gee.HashMap validate_res) {", + " ", + " this.error_line = validate_res.size;", + "", + " if (this.error_line < 1) {", + " return true;", + " }", + " var tlines = this.el.get_line_count ();", + " Gtk.TextIter iter;", + " var valiter = validate_res.map_iterator();", + " while (valiter.next()) {", + " ", + " // print(\"get inter\\n\");", + " var eline = valiter.get_key();", + " if (eline > tlines) {", + " continue;", + " }", + " this.el.get_iter_at_line( out iter, eline);", + " //print(\"mark line\\n\");", + " this.el.create_source_mark(valiter.get_value(), \"ERR\", iter);", + " } ", + " return false;", + " }" + ], + "| bool highlightErrorsJson" : [ + "(string type, Json.Object obj) {", + " Gtk.TextIter start;", + " Gtk.TextIter end; ", + " this.el.get_bounds (out start, out end);", + " ", + " this.el.remove_source_marks (start, end, type);", + " ", + " ", + " // we should highlight other types of errors..", + " ", + " if (!obj.has_member(type)) {", + " print(\"Return has no errors\\n\");", + " return true;", + " }", + " ", + " if (_this.window.windowstate.state != WindowState.State.CODEONLY ", + " ", + " ) {", + " return true;", + " } ", + " ", + " ", + " var err = obj.get_object_member(type);", + " ", + " ", + " if (_this.file == null) {", + " return true;", + " ", + " }", + " var valafn = _this.file.path;", + " ", + " if (_this.file.xtype != \"PlainFile\") {", + "", + "", + " ", + " ", + " valafn = \"\";", + " try { ", + " var regex = new Regex(\"\\\\.bjs$\");", + " // should not happen", + " ", + " ", + " valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , \".vala\");", + " } catch (GLib.RegexError e) {", + " return true;", + " } ", + "", + "", + "", + " }", + " if (!err.has_member(valafn)) {", + " print(\"File path has no errors\\n\");", + " return true;", + " }", + "", + " var lines = err.get_object_member(valafn);", + " ", + " var offset = 1;", + " if (obj.has_member(\"line_offset\")) {", + " offset = (int)obj.get_int_member(\"line_offset\") + 1;", + " }", + " ", + "", + " ", + " ", + " var tlines = this.el.get_line_count () +1;", + " ", + " lines.foreach_member((obj, line, node) => {", + " ", + " Gtk.TextIter iter;", + " // print(\"get inter\\n\");", + " var eline = int.parse(line) - offset;", + " print(\"GOT ERROR on line %s -- converted to %d\\n\", line,eline);", + " ", + " ", + " if (eline > tlines || eline < 0) {", + " return;", + " }", + " this.el.get_iter_at_line( out iter, eline);", + " //print(\"mark line\\n\");", + " var msg = \"Line: %d\".printf(eline+1);", + " var ar = lines.get_array_member(line);", + " for (var i = 0 ; i < ar.get_length(); i++) {", + "\t\t msg += (msg.length > 0) ? \"\\n\" : \"\";", + "\t\t msg += ar.get_string_element(i);", + "\t }", + " ", + " ", + " this.el.create_source_mark(msg, type, iter);", + " } );", + " return false;", + " ", + "", + "", + "", + "", + "}", + "" + ] } + ], + "listeners" : { + "key_release_event" : [ + " (event) => {", + " ", + " if (event.keyval == 115 && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {", + " print(\"SAVE: ctrl-S pressed\");", + " _this.saveContents();", + " return false;", + " }", + " // print(event.key.keyval)", + " ", + " return false;", + "", + "} ", + "", + " " + ] + }, + "uint tab_width" : 4, + "xtype" : "SourceView", + "| void load" : [ + " (string str) {", + "", + "// show the help page for the active node..", + " //this.get('/Help').show();", + "", + "", + " // this.get('/BottomPane').el.set_current_page(0);", + " var buf = (Gtk.SourceBuffer)this.el.get_buffer();", + " buf.set_text(str, str.length);", + " buf.set_undo_manager(null);", + " ", + " var lm = Gtk.SourceLanguageManager.get_default();", + " var lang = \"vala\";", + " if (_this.file != null) {", + " lang = _this.file.language;", + " }", + " print(\"lang=%s, content_type = %s\\n\", lang, _this.file.content_type);", + " var lg = _this.file.content_type.length > 0 ?", + " lm.guess_language(_this.file.path, _this.file.content_type) :", + " lm.get_language(lang);", + " ", + " ", + " ((Gtk.SourceBuffer)(this.el.get_buffer())) .set_language(lg); ", + "", + " this.el.insert_spaces_instead_of_tabs = true;", + " if (lg != null) {", + "\t\tprint(\"sourcelanguage = %s\\n\", lg.name);", + "\t\tif (lg.name == \"Vala\") {", + "\t\t this.el.insert_spaces_instead_of_tabs = false;", + "\t\t}", + " }", + " _this.dirty = false;", + " this.el.grab_focus();", + " _this.save_button.el.sensitive = false;", + "}" ] } - ] + ], + "xtype" : "ScrolledWindow" } + ], + "string id" : "Editor", + "xtype" : "Box", + "| bool saveContents" : [ + " () {", + " ", + " ", + " if (_this.file == null) {", + " return true;", + " }", + " ", + " ", + " ", + " ", + " ", + " var str = _this.buffer.toString();", + " ", + " _this.buffer.checkSyntax();", + " ", + " ", + " ", + " // LeftPanel.model.changed( str , false);", + " _this.dirty = false;", + " _this.save_button.el.sensitive = false;", + " ", + " // find the text for the node..", + " if (_this.file.xtype != \"PlainFile\") {", + " if (ptype == \"listener\") {", + " this.node.listeners.set(key,str);", + " ", + " } else {", + " this.node.props.set(key,str);", + " }", + " } else {", + " _this.file.setSource( str );", + " }", + " ", + " // call the signal..", + " this.save();", + " ", + " return true;", + "", + "} " + ], + "| void show" : [ + "(JsRender.JsRender file, JsRender.Node? node, string ptype, string key)", + "{", + " this.file = file; ", + " this.ptype = \"\";", + " this.key = \"\";", + " this.node = null;", + "\tthis.searchcontext = null;", + " ", + " if (file.xtype != \"PlainFile\") {", + " ", + " this.ptype = ptype;", + " this.key = key;", + " this.node = node;", + " string val = \"\";", + " // find the text for the node..", + " if (ptype == \"listener\") {", + " val = node.listeners.get(key);", + " ", + " } else {", + " val = node.props.get(key);", + " }", + " this.view.load(val);", + " this.key_edit.el.show();", + " this.key_edit.el.text = key; ", + " ", + " } else {", + " this.view.load( file.toSource() );", + " this.key_edit.el.hide();", + " }", + " ", + "}" + ], + "| int search" : [ + "(string txt) {", + "", + "\tvar s = new Gtk.SourceSearchSettings();", + "\t", + "\tthis.searchcontext = new Gtk.SourceSearchContext(this.buffer.el,s);", + "\tthis.searchcontext .set_highlight(true);", + "\ts.set_search_text(txt);", + "\tGtk.TextIter beg, st,en;", + "\t ", + "\tthis.buffer.el.get_start_iter(out beg);", + "\tthis.searchcontext.forward(beg, out st, out en);", + "\tthis.last_search_end = 0;", + "\t", + "\treturn this.searchcontext.get_occurrences_count();", + "", + " ", + " ", + "", + "}", + "" + ], + "| void forwardSearch" : [ + "(bool change_focus) {", + "", + "\tif (this.searchcontext == null) {", + "\t\treturn;", + "\t}", + "\t", + "\tGtk.TextIter beg, st,en;", + "\t ", + "\tthis.buffer.el.get_iter_at_offset(out beg, this.last_search_end);", + "\tif (!this.searchcontext.forward(beg, out st, out en)) {", + "\t", + "\t\tthis.last_search_end = 0;", + "\t} else {", + "\t\tthis.last_search_end = en.get_offset();", + "\t\tif (change_focus) {", + "\t\t\tthis.view.el.grab_focus();", + "\t\t}", + "\t\tthis.buffer.el.place_cursor(st);", + "\t\tthis.view.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f);", + "\t}", + " ", + "}", + "" + ], + "| void scroll_to_line" : [ + "(int line) {", + "", + "\tGLib.Timeout.add(500, () => {", + " ", + "\t\tvar buf = this.view.el.get_buffer();", + "", + "\t\tvar sbuf = (Gtk.SourceBuffer) buf;", + "", + "", + "\t\tGtk.TextIter iter; ", + "\t\tsbuf.get_iter_at_line(out iter, line);", + "\t\tthis.view.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);", + "\t\treturn false;", + "\t}); ", + "}", + "" ] } - ] + ], + "modOrder" : "", + "name" : "Editor", + "parent" : "", + "path" : "/home/alan/gitlive/roobuilder/src/Builder4/Editor.bjs", + "permname" : "", + "title" : "" } \ No newline at end of file diff --git a/src/Builder4/Editor.vala b/src/Builder4/Editor.vala index 07780832a..9a4d3f21c 100644 --- a/src/Builder4/Editor.vala +++ b/src/Builder4/Editor.vala @@ -165,8 +165,7 @@ public class Editor : Object this.view.load( file.toSource() ); this.key_edit.el.hide(); } - - + } public void forwardSearch (bool change_focus) { @@ -188,7 +187,7 @@ public class Editor : Object this.buffer.el.place_cursor(st); this.view.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f); } - + } public class Xcls_Box2 : Object { @@ -269,6 +268,7 @@ public class Editor : Object // set gobject values this.el.width_request = 100; + this.el.editable = false; } // user defined functions @@ -548,16 +548,6 @@ public class Editor : Object } return false; } - public string toString () { - - Gtk.TextIter s; - Gtk.TextIter e; - this.el.get_start_iter(out s); - this.el.get_end_iter(out e); - var ret = this.el.get_text(s,e,true); - //print("TO STRING? " + ret); - return ret; - } public bool checkSyntax () { if (this.check_running) { @@ -656,6 +646,16 @@ public class Editor : Object return true; // at present allow saving - even if it's invalid.. } + public string toString () { + + Gtk.TextIter s; + Gtk.TextIter e; + this.el.get_start_iter(out s); + this.el.get_end_iter(out e); + var ret = this.el.get_text(s,e,true); + //print("TO STRING? " + ret); + return ret; + } public bool highlightErrorsJson (string type, Json.Object obj) { Gtk.TextIter start; Gtk.TextIter end; @@ -671,8 +671,8 @@ public class Editor : Object return true; } - if (_this.window.windowstate.state != WindowState.State.CODEONLY && - _this.window.windowstate.state != WindowState.State.CODE + if (_this.window.windowstate.state != WindowState.State.CODEONLY + ) { return true; } diff --git a/src/Builder4/MainWindow.bjs b/src/Builder4/MainWindow.bjs index 5412b4696..ea3e6f716 100644 --- a/src/Builder4/MainWindow.bjs +++ b/src/Builder4/MainWindow.bjs @@ -1,757 +1,1336 @@ { - "name" : "MainWindow", - "parent" : "", - "title" : "", - "path" : "/home/alan/gitlive/roobuilder/src/Builder4/MainWindow.bjs", - "permname" : "", - "modOrder" : "", "build_module" : "builder", "items" : [ { - "listeners" : { - "delete_event" : " ( event) => {\n return false;\n} ", - "destroy" : "() => {\n Xcls_MainWindow.singleton().no_windows--;\n \n Resources.singleton().disconnect(_this.statusbar.handler_id);\n \n \n if (Xcls_MainWindow.singleton().no_windows < 1) {\n\n Gtk.main_quit();\n }\n}", - "show" : " ( ) => {\n // hide the file editing..\n \n //this.hideViewEditing();\n _this.statusbar.el.hide();\n _this.statusbar_errors.el.hide();\n _this.statusbar_warnings.el.hide();\n _this.statusbar_depricated.el.hide();\n _this.statusbar_compile_spinner.el.hide();\n \n Resources.singleton().checkResources();\n\n}", - "key_release_event" : " (event) => {\n \n if (this.search_entry.el.is_visible()) {\n\t\tif (event.keyval == Gdk.Key.f && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {\n\t\t print(\"SAVE: ctrl-f pressed\");\n\t\t\tthis.search_entry.el.grab_focus();\n\t\t return false;\n\t\t}\n\t\t\n\t\tif (event.keyval == Gdk.Key.g && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {\n\t\t print(\"SAVE: ctrl-g pressed\");\n\t\t\tthis.search_entry.forwardSearch(true);\n\t\t return false;\n\t\t}\n\t\t\n\t} \n\t\n\tif (event.keyval == Gdk.Key.n && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {\n\t\tprint(\"SAVE: ctrl-n pressed\");\n\t\tthis.openNewWindow();\n\t\treturn false;\n\t}\n\t\n // print(event.key.keyval)\n \n return false;\n\n} \n\n" - }, - "id" : "MainWindow", - "default_width" : 800, - "* init" : " \n\t \n //this.el.show_all();\n //try {\n this.el.set_icon_name(\"roobuilder\");\n\t//} catch (Exception e) {\n\t//\tprint(\"no icon found\");\n//\t}", - "| void openNewWindow" : "() {\n\tXcls_MainWindow.singleton().no_windows++;\n var w = new Xcls_MainWindow();\n w.ref();\n\n w.el.show_all();\n w.initChildren();\n w.windowstate.switchState(WindowState.State.FILES);\n}\n", "# Project.Project project" : "null", - "# string title" : "\"Roo Application Builder\"", - "xtype" : "Window", + "# WindowState windowstate" : "null", "# int no_windows" : 1, - "default_height" : 500, - "| void initChildren" : " () {\n // this needs putting in a better place..\n this.windowstate = new WindowState(this);\n \n\n //w.el.show_all();\n var tl = new Clutter.Timeline(6000);\n tl.set_repeat_count(-1);\n tl.start();\n tl.ref();\n\n \n\n\n\n}\n", + "# string title" : "\"Roo Application Builder\"", + "$ type" : "Gtk.WindowType.TOPLEVEL", "$ xns" : "Gtk", - "| void show" : "() {\n \n this.el.show_all();\n\n}", - "# WindowState windowstate" : "null", + "* init" : [ + " ", + "\t ", + " //this.el.show_all();", + " //try {", + " this.el.set_icon_name(\"roobuilder\");", + "\t//} catch (Exception e) {", + "\t//\tprint(\"no icon found\");", + "//\t}" + ], "border_width" : 0, - "$ type" : "Gtk.WindowType.TOPLEVEL", - "| void setTitle" : " (string str) {\n this.headerbar.el.set_title(this.title + \" - \" + str);\n} \n", + "default_height" : 500, + "default_width" : 800, + "id" : "MainWindow", "items" : [ { - "id" : "headerbar", - "xtype" : "HeaderBar", + "$ xns" : "Gtk", "* pack" : "set_titlebar", "bool show_close_button" : true, - "$ xns" : "Gtk", - "string title" : "Application Builder", + "id" : "headerbar", "items" : [ { - "* pack" : "pack_start", - "xtype" : "Box", "$ xns" : "Gtk", + "* pack" : "pack_start", "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL", "items" : [ { - "bool use_popover" : false, - "xtype" : "MenuButton", - "* pack" : "add", "$ xns" : "Gtk", + "* pack" : "add", + "bool use_popover" : false, "items" : [ { - "id" : "topbarmenu", - "* init" : "{\n this.el.show_all();\n}\n", - "xtype" : "Menu", - "* pack" : "set_popup", "$ xns" : "Gtk", + "* init" : [ + "{", + " this.el.show_all();", + "}", + "" + ], + "* pack" : "set_popup", + "id" : "topbarmenu", "items" : [ { + "$ xns" : "Gtk", + "* pack" : "append", "listeners" : { - "activate" : "( ) => {\n _this.openNewWindow();\n}" + "activate" : [ + "( ) => {", + " _this.openNewWindow();", + "}" + ] }, - "xtype" : "MenuItem", "string label" : "Open a new Window", - "* pack" : "append", - "$ xns" : "Gtk" + "xtype" : "MenuItem" }, { + "$ xns" : "Gtk", "* pack" : "append", - "xtype" : "SeparatorMenuItem", - "$ xns" : "Gtk" + "xtype" : "SeparatorMenuItem" }, { + "$ xns" : "Gtk", + "* pack" : "append", "listeners" : { - "activate" : " ( ) => {\n Resources.singleton().fetchStart();\n}" + "activate" : [ + " ( ) => {", + " Resources.singleton().fetchStart();", + "}" + ] }, - "* pack" : "append", - "xtype" : "MenuItem", "string label" : "Download updated Resources", - "$ xns" : "Gtk" + "xtype" : "MenuItem" }, { + "$ xns" : "Gtk", + "* pack" : "append", "listeners" : { - "activate" : "() => {\n About.singleton().el.show();\n }" + "activate" : [ + "() => {", + " About.singleton().el.show();", + " }" + ] }, "string label" : "About the Builder", - "* pack" : "append", - "xtype" : "MenuItem", - "$ xns" : "Gtk" + "xtype" : "MenuItem" } - ] + ], + "xtype" : "Menu" }, { - "xtype" : "Image", - "utf8 icon_name" : "help-about", + "$ xns" : "Gtk", "* pack" : "set_image", - "$ xns" : "Gtk" + "utf8 icon_name" : "help-about", + "xtype" : "Image" } - ] + ], + "xtype" : "MenuButton" }, { - "listeners" : { - "clicked" : " ( ) => {\n _this.windowstate.switchState(WindowState.State.FILES);\n \n\n}" - }, - "id" : "openbtn", - "* pack" : "add", - "xtype" : "Button", - "$ xns" : "Gtk", "$ tooltop_text" : "\"Open File\"", + "$ xns" : "Gtk", + "* pack" : "add", + "id" : "openbtn", "items" : [ { + "$ xns" : "Gtk", "* pack" : "set_image", - "xtype" : "Image", "utf8 icon_name" : "document-open", - "$ xns" : "Gtk" + "xtype" : "Image" } - ] - }, - { + ], "listeners" : { - "clicked" : " ( ) => {\n \n _this.windowstate.switchState(WindowState.State.PREVIEW);\n \n\n}" + "clicked" : [ + " ( ) => {", + " _this.windowstate.switchState(WindowState.State.FILES);", + " ", + "", + "}" + ] }, - "id" : "openbackbtn", - "utf8 tooltip_text" : "Back", - "xtype" : "Button", - "* pack" : "add", + "xtype" : "Button" + }, + { "$ xns" : "Gtk", + "* pack" : "add", "bool visible" : false, + "id" : "openbackbtn", "items" : [ { - "utf8 icon_name" : "go-previous", + "$ xns" : "Gtk", "* pack" : "set_image", - "xtype" : "Image", - "$ xns" : "Gtk" + "utf8 icon_name" : "go-previous", + "xtype" : "Image" } - ] + ], + "listeners" : { + "clicked" : [ + " ( ) => {", + " ", + " _this.windowstate.switchState(WindowState.State.PREVIEW);", + " ", + "", + "}" + ] + }, + "utf8 tooltip_text" : "Back", + "xtype" : "Button" } - ] + ], + "xtype" : "Box" } - ] + ], + "string title" : "Application Builder", + "xtype" : "HeaderBar" }, { - "id" : "vbox", - "* pack" : "add", - "xtype" : "Box", + "$ homogeneous" : false, "$ xns" : "Gtk", + "* pack" : "add", "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", - "$ homogeneous" : false, + "id" : "vbox", "items" : [ { - "id" : "mainpane", - "position" : 400, - "* pack" : "pack_start,true,true,0", "# int lastWidth" : 0, - "xtype" : "Paned", "$ xns" : "Gtk", + "* pack" : "pack_start,true,true,0", "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL", + "id" : "mainpane", "items" : [ { - "id" : "leftpane", - "xtype" : "Box", - "* pack" : "add1", "$ xns" : "Gtk", + "* pack" : "add1", "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", + "id" : "leftpane", "items" : [ { - "id" : "editpane", - "xtype" : "Paned", - "* pack" : "pack_start,true,true,0", "$ xns" : "Gtk", + "* pack" : "pack_start,true,true,0", "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", + "id" : "editpane", "items" : [ { - "id" : "tree", - "xtype" : "Box", - "* pack" : "add1", "$ xns" : "Gtk", - "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL" + "* pack" : "add1", + "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", + "id" : "tree", + "xtype" : "Box" }, { - "id" : "props", - "xtype" : "Box", - "* pack" : "add2", "$ xns" : "Gtk", - "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL" + "* pack" : "add2", + "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", + "id" : "props", + "xtype" : "Box" } - ] + ], + "xtype" : "Paned" } - ] + ], + "xtype" : "Box" }, { - "* pack" : "add2", - "xtype" : "Box", "$ xns" : "Gtk", + "* pack" : "add2", "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", "items" : [ { - "listeners" : { - "size_allocate" : " ( alloc) => {\n if (_this.windowstate == null) {\n return;\n }\n _this.windowstate.resizeCanvas(); \n \n}" - }, - "id" : "clutterembed", - "* init" : " var stage = this.el.get_stage();\n stage.set_background_color( Clutter.Color.from_string(\"#000\"));\n \n \n", - "xtype" : "Embed", - "* pack" : "pack_start,true,true,0", "$ xns" : "GtkClutter", + "* init" : [ + " var stage = this.el.get_stage();", + " stage.set_background_color( Clutter.Color.from_string(\"#000\"));", + " ", + " ", + "" + ], + "* pack" : "pack_start,true,true,0", + "id" : "clutterembed", "items" : [ { - "id" : "rooview", - "* init" : "{\n \n \n this.el.add_constraint(\n new Clutter.AlignConstraint(\n _this.clutterembed.el.get_stage(), \n Clutter.AlignAxis.X_AXIS,\n 1.0f\n )\n );\n \n //this.el.set_position(100,100);\n this.el.set_pivot_point(1.0f,1.0f);\n \n this.el.set_size(_this.clutterembed.el.get_stage().width-50,\n _this.clutterembed.el.get_stage().height);\n \n}", - "xtype" : "Actor", + "$ xns" : "GtkClutter", + "* init" : [ + "{", + " ", + " ", + " this.el.add_constraint(", + " new Clutter.AlignConstraint(", + " _this.clutterembed.el.get_stage(), ", + " Clutter.AlignAxis.X_AXIS,", + " 1.0f", + " )", + " );", + " ", + " //this.el.set_position(100,100);", + " this.el.set_pivot_point(1.0f,1.0f);", + " ", + " this.el.set_size(_this.clutterembed.el.get_stage().width-50,", + " _this.clutterembed.el.get_stage().height);", + " ", + "}" + ], "* pack" : "get_stage().add_child", - "$ xns" : "GtkClutter" + "id" : "rooview", + "xtype" : "Actor" }, { - "id" : "objectview", - "* init" : "{\n \n /*\n this.el.add_constraint(\n new Clutter.AlignConstraint(\n _this.clutterembed.el.get_stage(), \n Clutter.AlignAxis.X_AXIS,\n 0.0f\n )\n );\n */\n this.el.fixed_x = 50.0f;\n this.el.fixed_y = 0.0f;\n //this.el.set_position(100,100);\n this.el.set_pivot_point(0.0f,0.0f);\n this.el.set_scale(0.0f,1.0f);\n this.el.set_size((_this.clutterembed.el.get_stage().width-50)/2,\n _this.clutterembed.el.get_stage().height);\n \n}", - "xtype" : "Actor", + "$ xns" : "GtkClutter", + "* init" : [ + "{", + " ", + " /*", + " this.el.add_constraint(", + " new Clutter.AlignConstraint(", + " _this.clutterembed.el.get_stage(), ", + " Clutter.AlignAxis.X_AXIS,", + " 0.0f", + " )", + " );", + " */", + " this.el.fixed_x = 50.0f;", + " this.el.fixed_y = 0.0f;", + " //this.el.set_position(100,100);", + " this.el.set_pivot_point(0.0f,0.0f);", + " this.el.set_scale(0.0f,1.0f);", + " this.el.set_size((_this.clutterembed.el.get_stage().width-50)/2,", + " _this.clutterembed.el.get_stage().height);", + " ", + "}" + ], "* pack" : "get_stage().add_child", - "$ xns" : "GtkClutter" + "id" : "objectview", + "xtype" : "Actor" }, { - "id" : "codeeditview", - "* init" : "{\n \n /*\n this.el.add_constraint(\n new Clutter.AlignConstraint(\n _this.clutterembed.el.get_stage(), \n Clutter.AlignAxis.X_AXIS,\n 0.0f\n )\n );\n */\n this.el.fixed_x = 50.0f;\n this.el.fixed_y = 0.0f;\n //this.el.set_position(100,100);\n this.el.set_pivot_point(0.0f,0.0f);\n this.el.set_scale(0.0f,1.0f);\n this.el.set_size((_this.clutterembed.el.get_stage().width-50)/2,\n _this.clutterembed.el.get_stage().height);\n \n}", - "xtype" : "Actor", + "$ xns" : "GtkClutter", + "* init" : [ + "{", + " ", + " /*", + " this.el.add_constraint(", + " new Clutter.AlignConstraint(", + " _this.clutterembed.el.get_stage(), ", + " Clutter.AlignAxis.X_AXIS,", + " 0.0f", + " )", + " );", + " */", + " this.el.fixed_x = 50.0f;", + " this.el.fixed_y = 0.0f;", + " //this.el.set_position(100,100);", + " this.el.set_pivot_point(0.0f,0.0f);", + " this.el.set_scale(0.0f,1.0f);", + " this.el.set_size((_this.clutterembed.el.get_stage().width-50)/2,", + " _this.clutterembed.el.get_stage().height);", + " ", + "}" + ], "* pack" : "get_stage().add_child", - "$ xns" : "GtkClutter" + "id" : "codeeditview", + "xtype" : "Actor" }, { - "id" : "addpropsview", - "* init" : "{\n \n /*\n this.el.add_constraint(\n new Clutter.AlignConstraint(\n _this.clutterembed.el.get_stage(), \n Clutter.AlignAxis.X_AXIS,\n 0.0f\n )\n );\n */\n this.el.fixed_x = 50.0f;\n this.el.fixed_y = 0.0f;\n //this.el.set_position(100,100);\n this.el.set_pivot_point(0.0f,0.0f);\n this.el.set_scale(0.0f,1.0f);\n this.el.set_size((_this.clutterembed.el.get_stage().width-50)/2,\n _this.clutterembed.el.get_stage().height);\n \n}", - "xtype" : "Actor", + "$ xns" : "GtkClutter", + "* init" : [ + "{", + " ", + " /*", + " this.el.add_constraint(", + " new Clutter.AlignConstraint(", + " _this.clutterembed.el.get_stage(), ", + " Clutter.AlignAxis.X_AXIS,", + " 0.0f", + " )", + " );", + " */", + " this.el.fixed_x = 50.0f;", + " this.el.fixed_y = 0.0f;", + " //this.el.set_position(100,100);", + " this.el.set_pivot_point(0.0f,0.0f);", + " this.el.set_scale(0.0f,1.0f);", + " this.el.set_size((_this.clutterembed.el.get_stage().width-50)/2,", + " _this.clutterembed.el.get_stage().height);", + " ", + "}" + ], "* pack" : "get_stage().add_child", - "$ xns" : "GtkClutter" + "id" : "addpropsview", + "xtype" : "Actor" }, { - "id" : "buttonlayout", - "* init" : "{\n \n this.el.add_constraint(\n new Clutter.AlignConstraint(\n _this.clutterembed.el.get_stage(), \n Clutter.AlignAxis.X_AXIS,\n 0.0f\n )\n );\n \n \n //this.el.set_position(100,100);\n this.el.set_pivot_point(0.5f,0.5f);\n this.el.set_size(50,\n _this.clutterembed.el.get_stage().height);\n \n}", - "xtype" : "Actor", - "* pack" : "get_stage().add_child", "$ xns" : "Clutter", + "* init" : [ + "{", + " ", + " this.el.add_constraint(", + " new Clutter.AlignConstraint(", + " _this.clutterembed.el.get_stage(), ", + " Clutter.AlignAxis.X_AXIS,", + " 0.0f", + " )", + " );", + " ", + " ", + " //this.el.set_position(100,100);", + " this.el.set_pivot_point(0.5f,0.5f);", + " this.el.set_size(50,", + " _this.clutterembed.el.get_stage().height);", + " ", + "}" + ], + "* pack" : "get_stage().add_child", + "id" : "buttonlayout", "items" : [ { "$ orientation" : "Clutter.Orientation.VERTICAL", - "xtype" : "BoxLayout", "$ xns" : "Clutter", - "* prop" : "layout_manager" + "* prop" : "layout_manager", + "xtype" : "BoxLayout" }, { - "id" : "backbutton", + "$ xns" : "Clutter", "* init" : "this.el.set_size(50,50);", - "xtype" : "Actor", "* pack" : "add_child", - "$ xns" : "Clutter", + "id" : "backbutton", "items" : [ { + "$ xns" : "GtkClutter", "* init" : "((Gtk.Container)(this.el.get_widget())).add ( child_0.el);", - "xtype" : "Actor", "* pack" : "add_child", - "$ xns" : "GtkClutter", "items" : [ { - "listeners" : { - "clicked" : " ( ) => {\n // if (_this.windowstate.state == WindowState.State.FILEPROJECT) {\n \n//\t _this.windowstate.switchState(WindowState.State.FILES);\n // } else { \n\t _this.windowstate.switchState(WindowState.State.PREVIEW);\n // }\n \n\n}" - }, - "utf8 tooltip_text" : "Back", - "* pack" : false, - "xtype" : "Button", - "width_request" : 50, "$ xns" : "Gtk", + "* pack" : false, "height_request" : 50, "items" : [ { + "$ xns" : "Gtk", "* pack" : "set_image", - "xtype" : "Image", "utf8 icon_name" : "go-previous", - "$ xns" : "Gtk" + "xtype" : "Image" } - ] + ], + "listeners" : { + "clicked" : [ + " ( ) => {", + " // if (_this.windowstate.state == WindowState.State.FILEPROJECT) {", + " ", + "//\t _this.windowstate.switchState(WindowState.State.FILES);", + " // } else { ", + "\t _this.windowstate.switchState(WindowState.State.PREVIEW);", + " // }", + " ", + "", + "}" + ] + }, + "utf8 tooltip_text" : "Back", + "width_request" : 50, + "xtype" : "Button" } - ] + ], + "xtype" : "Actor" } - ] + ], + "xtype" : "Actor" }, { - "id" : "editfilebutton", + "$ xns" : "Clutter", "* init" : "this.el.set_size(50.0f,50.0f);", - "xtype" : "Actor", "* pack" : "add_child", - "$ xns" : "Clutter", + "id" : "editfilebutton", "items" : [ { + "$ xns" : "GtkClutter", "* init" : "((Gtk.Container)(this.el.get_widget())).add ( child_0.el);", "* pack" : "add_child", - "xtype" : "Actor", - "$ xns" : "GtkClutter", "items" : [ { - "listeners" : { - "clicked" : " ( ) => {\n \n // create a new file in project..\n if (_this.project == null || _this.windowstate.file == null) {\n return ;\n }\n _this.windowstate.file_details.show(\n _this.windowstate.file, this.el\n );\n \n return ; \n\n\n}" - }, - "* pack" : false, - "xtype" : "Button", - "width_request" : 50, - "$ xns" : "Gtk", "$ tooltip_text" : "\"File Details\"", + "$ xns" : "Gtk", + "* pack" : false, "height_request" : 50, "items" : [ { - "xtype" : "Image", - "utf8 icon_name" : "document-properties", + "$ xns" : "Gtk", "* pack" : "set_image", - "$ xns" : "Gtk" + "utf8 icon_name" : "document-properties", + "xtype" : "Image" } - ] + ], + "listeners" : { + "clicked" : [ + " ( ) => {", + " ", + " // create a new file in project..", + " if (_this.project == null || _this.windowstate.file == null) {", + " return ;", + " }", + " _this.windowstate.file_details.show(", + " _this.windowstate.file, this.el", + " );", + " ", + " return ; ", + "", + "", + "}" + ] + }, + "width_request" : 50, + "xtype" : "Button" } - ] + ], + "xtype" : "Actor" } - ] + ], + "xtype" : "Actor" }, { - "id" : "projecteditbutton", + "$ xns" : "Clutter", "* init" : "this.el.set_size(50,50);", - "xtype" : "Actor", "* pack" : "add_child", - "$ xns" : "Clutter", + "id" : "projecteditbutton", "items" : [ { + "$ xns" : "GtkClutter", "* init" : "((Gtk.Container)(this.el.get_widget())).add ( child_0.el);", "* pack" : "add_child", - "xtype" : "Actor", - "$ xns" : "GtkClutter", "items" : [ { - "listeners" : { - "clicked" : " ( ) => {\n \n _this.windowstate.projectPopoverShow(this.el);\n \n \n}" - }, - "* pack" : false, - "xtype" : "Button", - "width_request" : 50, - "$ xns" : "Gtk", "$ tooltip_text" : "\"Project Details\"", + "$ xns" : "Gtk", + "* pack" : false, "height_request" : 50, "items" : [ { + "$ xns" : "Gtk", "* pack" : "set_image", - "xtype" : "Image", "utf8 icon_name" : "emblem-system", - "$ xns" : "Gtk" + "xtype" : "Image" } - ] + ], + "listeners" : { + "clicked" : [ + " ( ) => {", + " ", + " _this.windowstate.projectPopoverShow(this.el);", + " ", + " ", + "}" + ] + }, + "width_request" : 50, + "xtype" : "Button" } - ] + ], + "xtype" : "Actor" } - ] + ], + "xtype" : "Actor" }, { - "listeners" : { - "enter_event" : "( event) => {\n this.el.background_color = Clutter.Color.from_string(\"#333\");\n return false;\n}", - "leave_event" : "( event) => {\n this.el.background_color = Clutter.Color.from_string(\"#000\");\n return false;\n}" - }, - "id" : "objectshowbutton", + "$ xns" : "Clutter", "* init" : "this.el.set_size(50,50);", - "xtype" : "Actor", "* pack" : "add_child", - "$ xns" : "Clutter", + "id" : "objectshowbutton", "items" : [ { + "$ xns" : "GtkClutter", "* init" : "((Gtk.Container)(this.el.get_widget())).add ( child_0.el);", "* pack" : "add_child", - "xtype" : "Actor", - "$ xns" : "GtkClutter", "items" : [ { - "listeners" : { - "clicked" : " ( ) => {\n \n _this.windowstate.switchState(WindowState.State.OBJECT);\n \n \n}" - }, - "* pack" : false, - "xtype" : "Button", - "width_request" : 50, - "$ xns" : "Gtk", "$ tooltip_text" : "\"Add Child Element\"", + "$ xns" : "Gtk", + "* pack" : false, "height_request" : 50, "items" : [ { - "utf8 icon_name" : "list-add", + "$ xns" : "Gtk", "* pack" : "set_image", - "xtype" : "Image", - "$ xns" : "Gtk" + "utf8 icon_name" : "list-add", + "xtype" : "Image" } - ] + ], + "listeners" : { + "clicked" : [ + " ( ) => {", + " ", + "", + " \t_this.windowstate.showAddObject(this.el);", + " ", + "}" + ] + }, + "width_request" : 50, + "xtype" : "Button" } - ] + ], + "xtype" : "Actor" } - ] + ], + "listeners" : { + "enter_event" : [ + "( event) => {", + " this.el.background_color = Clutter.Color.from_string(\"#333\");", + " return false;", + "}" + ], + "leave_event" : [ + "( event) => {", + " this.el.background_color = Clutter.Color.from_string(\"#000\");", + " return false;", + "}" + ] + }, + "xtype" : "Actor" }, { - "id" : "addpropbutton", + "$ xns" : "Clutter", "* init" : "this.el.set_size(50,50);", - "xtype" : "Actor", "* pack" : "add_child", - "$ xns" : "Clutter", + "id" : "addpropbutton", "items" : [ { + "$ xns" : "GtkClutter", "* init" : "((Gtk.Container)(this.el.get_widget())).add ( child_0.el);", "* pack" : "add_child", - "xtype" : "Actor", - "$ xns" : "GtkClutter", "items" : [ { - "listeners" : { - "clicked" : " ( ) => {\n \n _this.windowstate.switchState(WindowState.State.PROP);\n \n\n}" - }, - "* pack" : false, - "xtype" : "Button", - "width_request" : 50, - "$ xns" : "Gtk", "$ tooltip_text" : "\"Add Property\"", + "$ xns" : "Gtk", + "* pack" : false, "height_request" : 50, "items" : [ { - "xtype" : "Image", - "utf8 icon_name" : "format-justify-left", + "$ xns" : "Gtk", "* pack" : "set_image", - "$ xns" : "Gtk" + "utf8 icon_name" : "format-justify-left", + "xtype" : "Image" } - ] + ], + "listeners" : { + "clicked" : [ + " ( ) => {", + " ", + " _this.windowstate.showProps(this.el, \"props\");", + " ", + "", + "}" + ] + }, + "width_request" : 50, + "xtype" : "Button" } - ] + ], + "xtype" : "Actor" } - ] + ], + "xtype" : "Actor" }, { - "id" : "addlistenerbutton", + "$ xns" : "Clutter", "* init" : "this.el.set_size(50,50);", - "xtype" : "Actor", "* pack" : "add_child", - "$ xns" : "Clutter", + "id" : "addlistenerbutton", "items" : [ { + "$ xns" : "GtkClutter", "* init" : "((Gtk.Container)(this.el.get_widget())).add ( child_0.el);", "* pack" : "add_child", - "xtype" : "Actor", - "$ xns" : "GtkClutter", "items" : [ { - "listeners" : { - "clicked" : " ( ) => {\n \n _this.windowstate.switchState(WindowState.State.LISTENER);\n \n\n\n}" - }, - "* pack" : false, - "xtype" : "Button", - "width_request" : 50, - "$ xns" : "Gtk", "$ tooltip_text" : "\"Add Event Code\"", + "$ xns" : "Gtk", + "* pack" : false, "height_request" : 50, "items" : [ { + "$ xns" : "Gtk", "* pack" : "set_image", - "xtype" : "Image", "utf8 icon_name" : "appointment-new", - "$ xns" : "Gtk" + "xtype" : "Image" } - ] + ], + "listeners" : { + "clicked" : [ + " ( ) => {", + " ", + " ", + " _this.windowstate.showProps(this.el, \"signals\");", + "", + "", + "}" + ] + }, + "width_request" : 50, + "xtype" : "Button" } - ] + ], + "xtype" : "Actor" } - ] + ], + "xtype" : "Actor" }, { - "id" : "addprojectbutton", + "$ xns" : "Clutter", "* init" : "this.el.set_size(50.0f,50.0f);", - "xtype" : "Actor", "* pack" : "add_child", - "$ xns" : "Clutter", + "id" : "addprojectbutton", "items" : [ { + "$ xns" : "GtkClutter", "* init" : "((Gtk.Container)(this.el.get_widget())).add ( child_0.el);", "* pack" : "add_child", - "xtype" : "Actor", - "$ xns" : "GtkClutter", "items" : [ { - "listeners" : { - "clicked" : " ( ) => {\n \n // create a new file in project..\n //Xcls_DialogNewComponent.singleton().show(\n var pe = EditProject.singleton();\n pe.el.set_transient_for(_this.el);\n pe.el.set_modal(true); \n \n var p = pe.show();\n\n if (p == null) {\n return;\n }\n \n \n _this.windowstate.left_projects.is_loaded = false; \n _this.windowstate.left_projects.load();\n _this.windowstate.left_projects.selectProject(p);\n return ; \n\n\n}" - }, - "* pack" : false, - "xtype" : "Button", - "width_request" : 50, - "$ xns" : "Gtk", "$ tooltip_text" : "\"New\\nProj.\"", + "$ xns" : "Gtk", + "* pack" : false, "height_request" : 50, "items" : [ { - "xtype" : "Image", - "utf8 icon_name" : "folder-new", + "$ xns" : "Gtk", "* pack" : "set_image", - "$ xns" : "Gtk" + "utf8 icon_name" : "folder-new", + "xtype" : "Image" } - ] + ], + "listeners" : { + "clicked" : [ + " ( ) => {", + " ", + " // create a new file in project..", + " //Xcls_DialogNewComponent.singleton().show(", + " var pe = EditProject.singleton();", + " pe.el.set_transient_for(_this.el);", + " pe.el.set_modal(true); ", + " ", + " var p = pe.show();", + "", + " if (p == null) {", + " return;", + " }", + " ", + " ", + " _this.windowstate.left_projects.is_loaded = false; ", + " _this.windowstate.left_projects.load();", + " _this.windowstate.left_projects.selectProject(p);", + " return ; ", + "", + "", + "}" + ] + }, + "width_request" : 50, + "xtype" : "Button" } - ] + ], + "xtype" : "Actor" } - ] + ], + "xtype" : "Actor" }, { - "id" : "addfilebutton", + "$ xns" : "Clutter", "* init" : "this.el.set_size(50.0f,50.0f);", - "xtype" : "Actor", "* pack" : "add_child", - "$ xns" : "Clutter", + "id" : "addfilebutton", "items" : [ { + "$ xns" : "GtkClutter", "* init" : "((Gtk.Container)(this.el.get_widget())).add ( child_0.el);", "* pack" : "add_child", - "xtype" : "Actor", - "$ xns" : "GtkClutter", "items" : [ { - "listeners" : { - "clicked" : " () => {\n // create a new file in project..\n print(\"add file selected\\n\");\n // what's the currently selected project...\n var proj = _this.windowstate.left_projects.getSelectedProject();\n \n if (proj == null) {\n\t\tprint(\"no project selected?\\n\");\n return ;\n }\n \n print(\"creating file?\");\n \n var f = JsRender.JsRender.factory(proj.xtype, proj, \"\");\n _this.project = proj;\n print(\"showing popup?\");\n _this.windowstate.file_details.show(\n f, this.el\n );\n \n \n return ; \n}" - }, - "* pack" : false, - "xtype" : "Button", - "width_request" : 50, - "$ xns" : "Gtk", "$ tooltip_text" : "\"Add File\"", + "$ xns" : "Gtk", + "* pack" : false, "height_request" : 50, "items" : [ { - "utf8 icon_name" : "document-new", + "$ xns" : "Gtk", "* pack" : "set_image", - "xtype" : "Image", - "$ xns" : "Gtk" + "utf8 icon_name" : "document-new", + "xtype" : "Image" } - ] + ], + "listeners" : { + "clicked" : [ + " () => {", + " // create a new file in project..", + " print(\"add file selected\\n\");", + " // what's the currently selected project...", + " var proj = _this.windowstate.left_projects.getSelectedProject();", + " ", + " if (proj == null) {", + "\t\tprint(\"no project selected?\\n\");", + " return ;", + " }", + " ", + " print(\"creating file?\");", + " ", + " var f = JsRender.JsRender.factory(proj.xtype, proj, \"\");", + " _this.project = proj;", + " print(\"showing popup?\");", + " _this.windowstate.file_details.show(", + " f, this.el", + " );", + " ", + " ", + " return ; ", + "}" + ] + }, + "width_request" : 50, + "xtype" : "Button" } - ] + ], + "xtype" : "Actor" } - ] + ], + "xtype" : "Actor" }, { - "id" : "delprojectbutton", + "$ xns" : "Clutter", "* init" : "this.el.set_size(50,50);", - "xtype" : "Actor", "* pack" : "add_child", - "$ xns" : "Clutter", + "id" : "delprojectbutton", "items" : [ { + "$ xns" : "GtkClutter", "* init" : "((Gtk.Container)(this.el.get_widget())).add ( child_0.el);", "* pack" : "add_child", - "xtype" : "Actor", - "$ xns" : "GtkClutter", "items" : [ { - "listeners" : { - "clicked" : " ( ) => {\n \n var cd = DialogConfirm.singleton();\n cd.el.set_transient_for(_this.el);\n cd.el.set_modal(true);\n\n var project = _this.windowstate.left_projects.getSelectedProject();\n if (project == null) {\n print(\"SKIP - no project\\n\");\n return;\n }\n \n \n if (Gtk.ResponseType.YES != cd.show(\"Confirm\", \n \"Are you sure you want to delete project %s\".printf(project.name))) {\n return;\n }\n \n\n // confirm?\n Project.Project.remove(project);\n _this.project = null;\n \n _this.windowstate.left_projects.is_loaded = false;\n _this.windowstate.left_projects.load();\n _this.windowstate.clutterfiles.clearFiles();\n\n}" - }, - "* pack" : false, - "xtype" : "Button", - "width_request" : 50, - "$ xns" : "Gtk", "$ tooltip_text" : "\"Delete Project\"", + "$ xns" : "Gtk", + "* pack" : false, "height_request" : 50, "items" : [ { - "xtype" : "Image", - "utf8 icon_name" : "user-trash", + "$ xns" : "Gtk", "* pack" : "set_image", - "$ xns" : "Gtk" + "utf8 icon_name" : "user-trash", + "xtype" : "Image" } - ] + ], + "listeners" : { + "clicked" : [ + " ( ) => {", + " ", + " var cd = DialogConfirm.singleton();", + " cd.el.set_transient_for(_this.el);", + " cd.el.set_modal(true);", + "", + " var project = _this.windowstate.left_projects.getSelectedProject();", + " if (project == null) {", + " print(\"SKIP - no project\\n\");", + " return;", + " }", + " ", + " ", + " if (Gtk.ResponseType.YES != cd.show(\"Confirm\", ", + " \"Are you sure you want to delete project %s\".printf(project.name))) {", + " return;", + " }", + " ", + "", + " // confirm?", + " Project.Project.remove(project);", + " _this.project = null;", + " ", + " _this.windowstate.left_projects.is_loaded = false;", + " _this.windowstate.left_projects.load();", + " _this.windowstate.clutterfiles.clearFiles();", + "", + "}" + ] + }, + "width_request" : 50, + "xtype" : "Button" } - ] + ], + "xtype" : "Actor" } - ] + ], + "xtype" : "Actor" } - ] + ], + "xtype" : "Actor" } - ] + ], + "listeners" : { + "size_allocate" : [ + " ( alloc) => {", + " if (_this.windowstate == null) {", + " return;", + " }", + " _this.windowstate.resizeCanvas(); ", + " ", + "}" + ] + }, + "xtype" : "Embed" } - ] + ], + "xtype" : "Box" } - ] + ], + "position" : 400, + "xtype" : "Paned" }, { - "bool homogeneous" : false, - "xtype" : "Box", - "* pack" : "pack_end,false,true,0", "$ xns" : "Gtk", + "* pack" : "pack_end,false,true,0", "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL", + "bool homogeneous" : false, "items" : [ { - "string label" : " ", + "$ xns" : "Gtk", "* pack" : "pack_start,true,true,0", - "xtype" : "Label", - "$ xns" : "Gtk" + "string label" : " ", + "xtype" : "Label" }, { + "$ xns" : "Gtk", + "* init" : [ + "{", + " this.handler_id = Resources.singleton().updateProgress.connect((pos,total) => {", + " if (pos < 1) {", + " this.el.hide();", + " _this.mainpane.el.set_sensitive(true);", + " ", + " return;", + " }", + " _this.mainpane.el.set_sensitive(false);", + " this.el.show();", + " this.el.set_fraction ((1.0f * pos) / (1.0f * total));", + " this.el.set_text(\"Fetching Resource : %s/%s\".printf(pos.to_string(), total.to_string()));", + " ", + " });", + "}", + "" + ], + "* pack" : "pack_start,true,true,0", "bool show_text" : true, "id" : "statusbar", "ulong handler_id" : "-1", - "* init" : "{\n this.handler_id = Resources.singleton().updateProgress.connect((pos,total) => {\n if (pos < 1) {\n this.el.hide();\n _this.mainpane.el.set_sensitive(true);\n \n return;\n }\n _this.mainpane.el.set_sensitive(false);\n this.el.show();\n this.el.set_fraction ((1.0f * pos) / (1.0f * total));\n this.el.set_text(\"Fetching Resource : %s/%s\".printf(pos.to_string(), total.to_string()));\n \n });\n}\n", - "xtype" : "ProgressBar", - "* pack" : "pack_start,true,true,0", - "$ xns" : "Gtk" + "xtype" : "ProgressBar" }, { + "$ xns" : "Gtk", + "* init" : [ + "var description = Pango.FontDescription.from_string(\"monospace\");", + "\tdescription.set_size(8000);", + "\t this.el.override_font(description);", + "", + "" + ], + "* pack" : "pack_start,false,true,0", + "id" : "search_entry", "listeners" : { - "key_press_event" : "(event) => {\n \n \tif (event.keyval == Gdk.Key.Return) {\n\t\tthis.forwardSearch(false);\n\t return true;\n\n\t} \n // print(event.key.keyval)\n \n return false;\n\n} ", - "changed" : "() => {\n\tif (this.el.text == \"\") {\n\t\t_this.search_results.el.hide();\n\t\treturn;\n\t}\n\tvar res = 0;\n\tswitch(_this.windowstate.state) {\n\t\tcase WindowState.State.CODEONLY:\n\t\tcase WindowState.State.CODE:\n\t\t\t// search the code being edited..\n\t\t\tres = _this.windowstate.code_editor.search(this.el.text);\n\t\t\t\n\t\t\tbreak;\n\t\tcase WindowState.State.PREVIEW:\n\t\t\tif (_this.windowstate.file.xtype == \"Gtk\") {\n\t\t\t\t res = _this.windowstate.window_gladeview.search(this.el.text);\n\t\t\t} else { \n\t\t\t\t res = _this.windowstate.window_rooview.search(this.el.text);\t\t\t\n\t\t\t}\n\t\t\n\t\t\n\t\t\tbreak;\n\t}\n\t_this.search_results.el.show();\n\tif (res > 0) {\n\t\t_this.search_results.el.label = \"%d Matches\".printf(res);\n\t} else {\n\t\t_this.search_results.el.label = \"No Matches\";\n\t}\n\t\t\n\t\n\t\n}\n" + "changed" : [ + "() => {", + "\tif (this.el.text == \"\") {", + "\t\t_this.search_results.el.hide();", + "\t\treturn;", + "\t}", + "\tvar res = 0;", + "\tswitch(_this.windowstate.state) {", + "\t\tcase WindowState.State.CODEONLY:", + "\t\t///case WindowState.State.CODE:", + "\t\t\t// search the code being edited..", + "\t\t\tres = _this.windowstate.code_editor_tab.search(this.el.text);", + "\t\t\t", + "\t\t\tbreak;", + "\t\tcase WindowState.State.PREVIEW:", + "\t\t\tif (_this.windowstate.file.xtype == \"Gtk\") {", + "\t\t\t\t res = _this.windowstate.window_gladeview.search(this.el.text);", + "\t\t\t} else { ", + "\t\t\t\t res = _this.windowstate.window_rooview.search(this.el.text);\t\t\t", + "\t\t\t}", + "\t\t", + "\t\t", + "\t\t\tbreak;", + "\t}", + "\t_this.search_results.el.show();", + "\tif (res > 0) {", + "\t\t_this.search_results.el.label = \"%d Matches\".printf(res);", + "\t} else {", + "\t\t_this.search_results.el.label = \"No Matches\";", + "\t}", + "\t\t", + "\t", + "\t", + "}", + "" + ], + "key_press_event" : [ + "(event) => {", + " ", + " \tif (event.keyval == Gdk.Key.Return) {", + "\t\tthis.forwardSearch(false);", + "\t return true;", + "", + "\t} ", + " // print(event.key.keyval)", + " ", + " return false;", + "", + "} " + ] }, - "id" : "search_entry", - "* init" : "var description = Pango.FontDescription.from_string(\"monospace\");\n\tdescription.set_size(8000);\n\t this.el.override_font(description);\n\n", - "* pack" : "pack_start,false,true,0", "xtype" : "SearchEntry", - "$ xns" : "Gtk", - "| void forwardSearch" : "(bool change_focus) {\n\tswitch(_this.windowstate.state) {\n\t\tcase WindowState.State.CODEONLY:\n\t\tcase WindowState.State.CODE:\n\t\t\t// search the code being edited..\n\t\t\t_this.windowstate.code_editor.forwardSearch(change_focus);\n\t\t\t\n\t\t\tbreak;\n\t\tcase WindowState.State.PREVIEW:\n\t\t\tif (_this.windowstate.file.xtype == \"Gtk\") {\n\t\t\t\t_this.windowstate.window_gladeview.forwardSearch(change_focus);\n\t\t\t} else { \n\t\t\t\t _this.windowstate.window_rooview.forwardSearch(change_focus);\n\t\t\t}\n\t\t\n\t\t\tbreak;\n\t}\n\t\n}\n" + "| void forwardSearch" : [ + "(bool change_focus) {", + "\tswitch(_this.windowstate.state) {", + "\t\tcase WindowState.State.CODEONLY:", + "\t\t//case WindowState.State.CODE:", + "\t\t\t// search the code being edited..", + "\t\t\t_this.windowstate.code_editor_tab.forwardSearch(change_focus);", + "\t\t\t ", + "\t\t\tbreak;", + "\t\tcase WindowState.State.PREVIEW:", + "\t\t\tif (_this.windowstate.file.xtype == \"Gtk\") {", + "\t\t\t\t_this.windowstate.window_gladeview.forwardSearch(change_focus);", + "\t\t\t} else { ", + "\t\t\t\t _this.windowstate.window_rooview.forwardSearch(change_focus);", + "\t\t\t}", + "\t\t", + "\t\t\tbreak;", + "\t}", + "\t", + "}", + "" + ] }, { - "xtype" : "MenuBar", - "* pack" : "add", "$ xns" : "Gtk", + "* pack" : "add", "items" : [ { - "listeners" : { - "button_press_event" : "() => {\n/*\n if (this.popup == null) {\n this.popup = new Xcls_ValaCompileErrors();\n this.popup.window = _this;\n }\n \n \n this.popup.show(this.notices, this.el);\n */\n return true;\n}" - }, + "$ xns" : "Gtk", + "* pack" : "add", + "Xcls_ValaCompileErrors popup" : "", "bool always_show_image" : true, "id" : "search_results", - "Xcls_ValaCompileErrors popup" : "", - "string label" : "Matches", - "* pack" : "add", - "xtype" : "ImageMenuItem", - "$ xns" : "Gtk", "items" : [ { - "utf8 icon_name" : "system-search", + "$ xns" : "Gtk", "* pack" : "set_image", - "xtype" : "Image", "bool sensitive" : false, - "$ xns" : "Gtk" + "utf8 icon_name" : "system-search", + "xtype" : "Image" } - ] + ], + "listeners" : { + "button_press_event" : [ + "() => {", + "/*", + " if (this.popup == null) {", + " this.popup = new Xcls_ValaCompileErrors();", + " this.popup.window = _this;", + " }", + " ", + " ", + " this.popup.show(this.notices, this.el);", + " */", + " return true;", + "}" + ] + }, + "string label" : "Matches", + "xtype" : "ImageMenuItem" }, { - "id" : "statusbar_compilestatus_label", - "xtype" : "MenuItem", + "$ xns" : "Gtk", "* pack" : "add", + "id" : "statusbar_compilestatus_label", "string label" : "Compile Status:", - "$ xns" : "Gtk" + "xtype" : "MenuItem" }, { - "listeners" : { - "button_press_event" : "() => {\n if (this.popup == null) {\n this.popup = new Xcls_ValaCompileErrors();\n this.popup.window = _this;\n }\n \n \n this.popup.show(this.notices, this.el);\n return true;\n}" - }, - "bool always_show_image" : true, - "id" : "statusbar_errors", - "| void setNotices" : "(Json.Object nots, int qty) {\n this.el.show();\n this.el.label = qty.to_string() + \" Errors\";\n this.notices = nots;\n\n}\n", - "Xcls_ValaCompileErrors popup" : "", - "string label" : "Errors", - "* pack" : "add", - "xtype" : "ImageMenuItem", "# Json.Object notices" : "new Json.Object() ", "$ xns" : "Gtk", + "* pack" : "add", + "Xcls_ValaCompileErrors popup" : "", + "bool always_show_image" : true, + "id" : "statusbar_errors", "items" : [ { + "$ xns" : "Gtk", "* pack" : "set_image", - "xtype" : "Image", "utf8 icon_name" : "dialog-error", - "$ xns" : "Gtk" + "xtype" : "Image" } - ] - }, - { + ], "listeners" : { - "button_press_event" : "() => {\n if (this.popup == null) {\n this.popup = new Xcls_ValaCompileErrors();\n this.popup.window = _this;\n }\n \n this.popup.show(this.notices, this.el);\n return true;\n}" + "button_press_event" : [ + "() => {", + " if (this.popup == null) {", + " this.popup = new Xcls_ValaCompileErrors();", + " this.popup.window = _this;", + " }", + " ", + " ", + " this.popup.show(this.notices, this.el);", + " return true;", + "}" + ] }, - "bool always_show_image" : true, - "id" : "statusbar_warnings", - "| void setNotices" : "(Json.Object nots, int qty) {\n this.el.show();\n this.el.label = qty.to_string() + \" Warnings\";\n this.notices = nots;\n\n}\n", - "Xcls_ValaCompileErrors popup" : "", - "* pack" : "add", - "string label" : "Warnings", + "string label" : "Errors", "xtype" : "ImageMenuItem", + "| void setNotices" : [ + "(Json.Object nots, int qty) {", + " this.el.show();", + " this.el.label = qty.to_string() + \" Errors\";", + " this.notices = nots;", + "", + "}", + "" + ] + }, + { "# Json.Object notices" : "new Json.Object()", "$ xns" : "Gtk", + "* pack" : "add", + "Xcls_ValaCompileErrors popup" : "", + "bool always_show_image" : true, + "id" : "statusbar_warnings", "items" : [ { - "utf8 icon_name" : "dialog-warning", + "$ xns" : "Gtk", "* pack" : "set_image", - "xtype" : "Image", - "$ xns" : "Gtk" + "utf8 icon_name" : "dialog-warning", + "xtype" : "Image" } - ] - }, - { + ], "listeners" : { - "button_press_event" : "() => {\n if (this.popup == null) {\n this.popup = new Xcls_ValaCompileErrors();\n this.popup.window = _this;\n }\n \n \n this.popup.show(this.notices, this.el);\n return true;\n}" + "button_press_event" : [ + "() => {", + " if (this.popup == null) {", + " this.popup = new Xcls_ValaCompileErrors();", + " this.popup.window = _this;", + " }", + " ", + " this.popup.show(this.notices, this.el);", + " return true;", + "}" + ] }, - "bool always_show_image" : true, - "id" : "statusbar_depricated", - "| void setNotices" : "(Json.Object nots, int qty) {\n this.el.show();\n this.el.label = qty.to_string() + \" Depricated\";\n this.notices = nots;\n\n}\n", - "Xcls_ValaCompileErrors popup" : "", - "string label" : "Depricated", - "* pack" : "add", + "string label" : "Warnings", "xtype" : "ImageMenuItem", + "| void setNotices" : [ + "(Json.Object nots, int qty) {", + " this.el.show();", + " this.el.label = qty.to_string() + \" Warnings\";", + " this.notices = nots;", + "", + "}", + "" + ] + }, + { "# Json.Object notices" : "new Json.Object()", "$ xns" : "Gtk", + "* pack" : "add", + "Xcls_ValaCompileErrors popup" : "", + "bool always_show_image" : true, + "id" : "statusbar_depricated", "items" : [ { - "xtype" : "Image", - "utf8 icon_name" : "dialog-information", + "$ xns" : "Gtk", "* pack" : "set_image", - "$ xns" : "Gtk" + "utf8 icon_name" : "dialog-information", + "xtype" : "Image" } + ], + "listeners" : { + "button_press_event" : [ + "() => {", + " if (this.popup == null) {", + " this.popup = new Xcls_ValaCompileErrors();", + " this.popup.window = _this;", + " }", + " ", + " ", + " this.popup.show(this.notices, this.el);", + " return true;", + "}" + ] + }, + "string label" : "Depricated", + "xtype" : "ImageMenuItem", + "| void setNotices" : [ + "(Json.Object nots, int qty) {", + " this.el.show();", + " this.el.label = qty.to_string() + \" Depricated\";", + " this.notices = nots;", + "", + "}", + "" ] }, { - "listeners" : { - "button_press_event" : "() => {\n\tif (_this.windowstate.file == null) {\n\t\treturn true;\n\t}\n\t_this.windowstate.valasource.spawnExecute(_this.windowstate.file);\n\t\n\t_this.windowstate.compile_results.show(this.el,true);\n\t\n\treturn true;\n}" - }, + "$ xns" : "Gtk", + "* pack" : "add", + "Xcls_ValaCompileErrors popup" : "", "bool always_show_image" : true, "id" : "statusbar_run", - "Xcls_ValaCompileErrors popup" : "", - "string label" : "Run", - "* pack" : "add", - "xtype" : "ImageMenuItem", - "$ xns" : "Gtk", "items" : [ { - "utf8 icon_name" : "media-playback-start", + "$ xns" : "Gtk", "* pack" : "set_image", - "xtype" : "Image", - "$ xns" : "Gtk" + "utf8 icon_name" : "media-playback-start", + "xtype" : "Image" } - ] + ], + "listeners" : { + "button_press_event" : [ + "() => {", + "\tif (_this.windowstate.file == null) {", + "\t\treturn true;", + "\t}", + "\t_this.windowstate.valasource.spawnExecute(_this.windowstate.file);", + "\t", + "\t_this.windowstate.compile_results.show(this.el,true);", + "\t", + "\treturn true;", + "}" + ] + }, + "string label" : "Run", + "xtype" : "ImageMenuItem" } - ] + ], + "xtype" : "MenuBar" }, { - "id" : "statusbar_compile_spinner", - "xtype" : "Spinner", + "$ xns" : "Gtk", "* pack" : "add", - "| void stop" : "() {\n this.el.stop();\n this.el.hide();\n}\n", + "id" : "statusbar_compile_spinner", "string tooltip_text" : "Compiling", - "$ xns" : "Gtk", - "| void start" : "() {\n this.el.show();\n this.el.start(); \n}\n" + "xtype" : "Spinner", + "| void start" : [ + "() {", + " this.el.show();", + " this.el.start(); ", + "}", + "" + ], + "| void stop" : [ + "() {", + " this.el.stop();", + " this.el.hide();", + "}", + "" + ] } - ] + ], + "xtype" : "Box" } - ] + ], + "xtype" : "Box" } + ], + "listeners" : { + "delete_event" : [ + " ( event) => {", + " return false;", + "} " + ], + "destroy" : [ + "() => {", + " Xcls_MainWindow.singleton().no_windows--;", + " ", + " Resources.singleton().disconnect(_this.statusbar.handler_id);", + " ", + " ", + " if (Xcls_MainWindow.singleton().no_windows < 1) {", + "", + " Gtk.main_quit();", + " }", + "}" + ], + "key_release_event" : [ + " (event) => {", + " ", + " if (this.search_entry.el.is_visible()) {", + "\t\tif (event.keyval == Gdk.Key.f && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {", + "\t\t print(\"SAVE: ctrl-f pressed\");", + "\t\t\tthis.search_entry.el.grab_focus();", + "\t\t return false;", + "\t\t}", + "\t\t", + "\t\tif (event.keyval == Gdk.Key.g && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {", + "\t\t print(\"SAVE: ctrl-g pressed\");", + "\t\t\tthis.search_entry.forwardSearch(true);", + "\t\t return false;", + "\t\t}", + "\t\t", + "\t} ", + "\t", + "\tif (event.keyval == Gdk.Key.n && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {", + "\t\tprint(\"SAVE: ctrl-n pressed\");", + "\t\tthis.openNewWindow();", + "\t\treturn false;", + "\t}", + "\t", + " // print(event.key.keyval)", + " ", + " return false;", + "", + "} ", + "", + "" + ], + "show" : [ + " ( ) => {", + " // hide the file editing..", + " ", + " //this.hideViewEditing();", + " _this.statusbar.el.hide();", + " _this.statusbar_errors.el.hide();", + " _this.statusbar_warnings.el.hide();", + " _this.statusbar_depricated.el.hide();", + " _this.statusbar_compile_spinner.el.hide();", + " ", + " Resources.singleton().checkResources();", + "", + "}" + ] + }, + "xtype" : "Window", + "| void setTitle" : [ + " (string str) {", + " this.headerbar.el.set_title(this.title + \" - \" + str);", + "} ", + "" + ], + "| void show" : [ + "() {", + " ", + " this.el.show_all();", + "", + "}" + ], + "| void initChildren" : [ + " () {", + " // this needs putting in a better place..", + " this.windowstate = new WindowState(this);", + " ", + "", + " //w.el.show_all();", + " var tl = new Clutter.Timeline(6000);", + " tl.set_repeat_count(-1);", + " tl.start();", + " tl.ref();", + "", + " ", + "", + "", + "", + "}", + "" + ], + "| void openNewWindow" : [ + "() {", + "\tXcls_MainWindow.singleton().no_windows++;", + " var w = new Xcls_MainWindow();", + " w.ref();", + "", + " w.el.show_all();", + " w.initChildren();", + " w.windowstate.switchState(WindowState.State.FILES);", + "}", + "" ] } - ] + ], + "modOrder" : "", + "name" : "MainWindow", + "parent" : "", + "path" : "/home/alan/gitlive/roobuilder/src/Builder4/MainWindow.bjs", + "permname" : "", + "title" : "" } \ No newline at end of file diff --git a/src/Builder4/MainWindow.vala b/src/Builder4/MainWindow.vala index 19e2b74d3..607c03e9c 100644 --- a/src/Builder4/MainWindow.vala +++ b/src/Builder4/MainWindow.vala @@ -1519,8 +1519,8 @@ public class Xcls_MainWindow : Object //listeners this.el.clicked.connect( ( ) => { - _this.windowstate.switchState(WindowState.State.OBJECT); - + + _this.windowstate.showAddObject(this.el); }); } @@ -1636,7 +1636,7 @@ public class Xcls_MainWindow : Object //listeners this.el.clicked.connect( ( ) => { - _this.windowstate.switchState(WindowState.State.PROP); + _this.windowstate.showProps(this.el, "props"); }); @@ -1753,8 +1753,8 @@ public class Xcls_MainWindow : Object //listeners this.el.clicked.connect( ( ) => { - _this.windowstate.switchState(WindowState.State.LISTENER); - + + _this.windowstate.showProps(this.el, "signals"); }); @@ -2347,9 +2347,9 @@ public class Xcls_MainWindow : Object var res = 0; switch(_this.windowstate.state) { case WindowState.State.CODEONLY: - case WindowState.State.CODE: + ///case WindowState.State.CODE: // search the code being edited.. - res = _this.windowstate.code_editor.search(this.el.text); + res = _this.windowstate.code_editor_tab.search(this.el.text); break; case WindowState.State.PREVIEW: @@ -2378,10 +2378,10 @@ public class Xcls_MainWindow : Object public void forwardSearch (bool change_focus) { switch(_this.windowstate.state) { case WindowState.State.CODEONLY: - case WindowState.State.CODE: + //case WindowState.State.CODE: // search the code being edited.. - _this.windowstate.code_editor.forwardSearch(change_focus); - + _this.windowstate.code_editor_tab.forwardSearch(change_focus); + break; case WindowState.State.PREVIEW: if (_this.windowstate.file.xtype == "Gtk") { diff --git a/src/Builder4/PopoverAddObject.bjs b/src/Builder4/PopoverAddObject.bjs new file mode 100644 index 000000000..1f56151fc --- /dev/null +++ b/src/Builder4/PopoverAddObject.bjs @@ -0,0 +1,256 @@ +{ + "build_module" : "", + "items" : [ + { + "$ xns" : "Gtk", + "@ void after_node_change" : "(JsRender.Node? node)", + "@ void before_node_change" : "(JsRender.Node? node)", + "@ void drag_end" : "()", + "Gtk.PositionType position" : "Gtk.PositionType.RIGHT", + "Xcls_MainWindow mainwindow" : "", + "bool active" : false, + "bool hexpand" : false, + "bool modal" : true, + "id" : "PopoverAddObject", + "int height_request" : 800, + "int width_request" : 900, + "items" : [ + { + "$ shadow_type" : "Gtk.ShadowType.IN", + "$ xns" : "Gtk", + "* init" : [ + " this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);", + " this.el.set_size_request(-1,200);", + " ", + "" + ], + "* pack" : "add", + "items" : [ + { + "# string dragData" : "", + "$ enable_tree_lines" : true, + "$ headers_visible" : true, + "$ xns" : "Gtk", + "* init" : [ + " {", + " this.el.set_size_request(150,-1);", + " // set_reorderable: [1]", + " ", + " var description = new Pango.FontDescription();", + " description.set_size(10000);", + " this.el.override_font(description);", + " ", + " var selection = this.el.get_selection();", + " selection.set_mode( Gtk.SelectionMode.SINGLE);", + " // this.selection.signal['changed'].connect(function() {", + " // _view.listeners['cursor-changed'].apply(_view, [ _view, '']);", + " //});", + " // see: http://live.gnome.org/GnomeLove/DragNDropTutorial", + " ", + " Gtk.drag_source_set (", + " this.el, /* widget will be drag-able */", + " Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */", + " BuilderApplication.targetList, /* lists of target to support */", + " Gdk.DragAction.COPY /* what to do with data after dropped */", + " );", + " //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList);", + " ", + " // Gtk.drag_source_set_target_list(this.el, Application.targetList);", + " // Gtk.drag_source_add_text_targets(this.el); ", + " ", + "}", + "" + ], + "* pack" : "add", + "items" : [ + { + "$ columns" : "typeof(string),typeof(string)", + "$ xns" : "Gtk", + "* pack" : "set_model", + "id" : "model", + "n_columns" : 2, + "xtype" : "ListStore", + "| string getValue" : [ + " (Gtk.TreeIter iter, int col) {", + "\tGLib.Value gval;", + "\tthis.el.get_value(iter, col , out gval);", + "\treturn (string)gval;", + " ", + "}" + ] + }, + { + "$ xns" : "Gtk", + "* init" : [ + " this.el.add_attribute(_this.txtrender.el , \"markup\", 1 );", + " ", + "" + ], + "* pack" : "append_column", + "items" : [ + { + "$ xns" : "Gtk", + "* pack" : "pack_start,true", + "id" : "txtrender", + "xtype" : "CellRendererText" + } + ], + "utf8 title" : "Drag to add Object", + "xtype" : "TreeViewColumn" + } + ], + "listeners" : { + "button_press_event" : [ + " ( event) => {", + "", + " //\tif (!this.get('/Editor').save()) {", + " //\t // popup!! - click handled.. ", + "// \t return true;", + "// }", + " return false;", + "}" + ], + "drag_begin" : [ + " ( ctx) => {", + " // we could fill this in now...", + "// Seed.print('SOURCE: drag-begin');", + " ", + " ", + " ", + " Gtk.TreeIter iter;", + " var s = this.el.get_selection();", + " ", + " Gtk.TreeModel mod;", + " s.get_selected(out mod, out iter);", + " var path = mod.get_path(iter);", + " ", + " /// pix is a surface..", + " var pix = this.el.create_row_drag_icon ( path);", + " ", + " ", + " Gtk.drag_set_icon_surface (ctx, pix);", + " GLib.Value value;", + " ", + "", + " _this.model.el.get_value(iter, 0, out value);", + " ", + " this.dragData = (string) value;", + " ", + " ", + " return;", + "}" + ], + "drag_data_get" : [ + "(drag_context, selection_data, info, time) => {", + " \t//Seed.print('Palete: drag-data-get: ' + target_type);", + " if (this.dragData.length < 1 ) {", + " return; ", + " }", + " ", + " GLib.debug(\"setting drag data to %s\\n\", this.dragData);", + " // selection_data.set_text(this.dragData ,this.dragData.length);", + " selection_data.set (selection_data.get_target (), 8, (uchar[]) this.dragData.to_utf8 ());", + "", + " //this.el.dragData = \"TEST from source widget\";", + " ", + " ", + "}" + ], + "drag_end" : [ + "( drag_context) => {", + " \t GLib.debug(\"SOURCE: drag-end (call listener on this)\\n\");", + "\t", + "\tthis.dragData = \"\";", + "\t//this.dropList = null;", + "\t_this.drag_end(); // call signal..", + "\t//this.get('/LeftTree.view').highlight(false);", + "\t ", + "}" + ] + }, + "xtype" : "TreeView" + } + ], + "xtype" : "ScrolledWindow" + } + ], + "xtype" : "Popover", + "| void clear" : [ + "() {", + " this.model.el.clear();", + "}", + "" + ], + "| void hide" : [ + "() {", + " ", + "\tthis.el.hide();", + "}", + "" + ], + "| void show" : [ + "(Palete.Palete pal, string cls, Gtk.Widget onbtn) {", + "", + " ", + " ", + " ", + "", + " var tr = pal.getChildList(cls);", + " this.model.el.clear();", + "", + "", + " Gtk.TreeIter citer;", + "", + " for(var i =0 ; i < tr.length; i++) {", + " this.model.el.append(out citer); ", + " var dname = tr[i];", + " if (dname.contains(\":\")) {", + "\t\t\tvar ar = dname.split(\":\");", + "\t\t\tdname = \"\" + ar[1] +\" - \"+ar[0]+\"\";", + "\t\t}", + " ", + " this.model.el.set_value(citer, 0, tr[i] ); // used data. ", + " this.model.el.set_value(citer, 1, dname ); // displayed value.", + " ", + " }", + " this.model.el.set_sort_column_id(1,Gtk.SortType.ASCENDING);", + " ", + " ", + " ", + " ", + " ", + " // set size up...", + " ", + " this.model.el.set_sort_column_id(0,Gtk.SortType.ASCENDING);", + " int w,h;", + " this.mainwindow.el.get_size(out w, out h);", + " ", + " // left tree = 250, editor area = 500?", + " ", + " // min 450?", + "\t// max hieght ...", + " this.el.set_size_request( 350, h); // full height?", + "", + " ", + "", + " if (this.el.relative_to == null) {", + " this.el.set_relative_to(onbtn);", + " }", + " this.el.show_all();", + " ", + " while(Gtk.events_pending()) { ", + " Gtk.main_iteration();", + " } ", + " // this.hpane.el.set_position( 0);", + "}", + "" + ] + } + ], + "modOrder" : "", + "name" : "PopoverAddObject", + "parent" : "", + "path" : "/home/alan/gitlive/roobuilder/src/Builder4/PopoverAddObject.bjs", + "permname" : "", + "title" : "" +} \ No newline at end of file diff --git a/src/Builder4/PopoverAddObject.vala b/src/Builder4/PopoverAddObject.vala new file mode 100644 index 000000000..9ebadf535 --- /dev/null +++ b/src/Builder4/PopoverAddObject.vala @@ -0,0 +1,342 @@ +static Xcls_PopoverAddObject _PopoverAddObject; + +public class Xcls_PopoverAddObject : Object +{ + public Gtk.Popover el; + private Xcls_PopoverAddObject _this; + + public static Xcls_PopoverAddObject singleton() + { + if (_PopoverAddObject == null) { + _PopoverAddObject= new Xcls_PopoverAddObject(); + } + return _PopoverAddObject; + } + public Xcls_model model; + public Xcls_txtrender txtrender; + + // my vars (def) + public bool active; + public signal void before_node_change (JsRender.Node? node); + public signal void drag_end (); + public Xcls_MainWindow mainwindow; + public signal void after_node_change (JsRender.Node? node); + + // ctor + public Xcls_PopoverAddObject() + { + _this = this; + this.el = new Gtk.Popover( null ); + + // my vars (dec) + this.active = false; + + // set gobject values + this.el.width_request = 900; + this.el.height_request = 800; + this.el.hexpand = false; + this.el.modal = true; + this.el.position = Gtk.PositionType.RIGHT; + var child_0 = new Xcls_ScrolledWindow2( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + } + + // user defined functions + public void show (Palete.Palete pal, string cls, Gtk.Widget onbtn) { + + + + + + var tr = pal.getChildList(cls); + this.model.el.clear(); + + + Gtk.TreeIter citer; + + for(var i =0 ; i < tr.length; i++) { + this.model.el.append(out citer); + var dname = tr[i]; + if (dname.contains(":")) { + var ar = dname.split(":"); + dname = "" + ar[1] +" - "+ar[0]+""; + } + + this.model.el.set_value(citer, 0, tr[i] ); // used data. + this.model.el.set_value(citer, 1, dname ); // displayed value. + + } + this.model.el.set_sort_column_id(1,Gtk.SortType.ASCENDING); + + + + + + // set size up... + + this.model.el.set_sort_column_id(0,Gtk.SortType.ASCENDING); + int w,h; + this.mainwindow.el.get_size(out w, out h); + + // left tree = 250, editor area = 500? + + // min 450? + // max hieght ... + this.el.set_size_request( 350, h); // full height? + + + + if (this.el.relative_to == null) { + this.el.set_relative_to(onbtn); + } + this.el.show_all(); + + while(Gtk.events_pending()) { + Gtk.main_iteration(); + } + // this.hpane.el.set_position( 0); + } + public void hide () { + + this.el.hide(); + } + public void clear () { + this.model.el.clear(); + } + public class Xcls_ScrolledWindow2 : Object + { + public Gtk.ScrolledWindow el; + private Xcls_PopoverAddObject _this; + + + // my vars (def) + + // ctor + public Xcls_ScrolledWindow2(Xcls_PopoverAddObject _owner ) + { + _this = _owner; + this.el = new Gtk.ScrolledWindow( null, null ); + + // my vars (dec) + + // set gobject values + this.el.shadow_type = Gtk.ShadowType.IN; + var child_0 = new Xcls_TreeView3( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + + // init method + + this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); + this.el.set_size_request(-1,200); + } + + // user defined functions + } + public class Xcls_TreeView3 : Object + { + public Gtk.TreeView el; + private Xcls_PopoverAddObject _this; + + + // my vars (def) + public string dragData; + + // ctor + public Xcls_TreeView3(Xcls_PopoverAddObject _owner ) + { + _this = _owner; + this.el = new Gtk.TreeView(); + + // my vars (dec) + + // set gobject values + this.el.enable_tree_lines = true; + this.el.headers_visible = true; + var child_0 = new Xcls_model( _this ); + child_0.ref(); + this.el.set_model ( child_0.el ); + var child_1 = new Xcls_TreeViewColumn5( _this ); + child_1.ref(); + this.el.append_column ( child_1.el ); + + // init method + + { + this.el.set_size_request(150,-1); + // set_reorderable: [1] + + var description = new Pango.FontDescription(); + description.set_size(10000); + this.el.override_font(description); + + var selection = this.el.get_selection(); + selection.set_mode( Gtk.SelectionMode.SINGLE); + // this.selection.signal['changed'].connect(function() { + // _view.listeners['cursor-changed'].apply(_view, [ _view, '']); + //}); + // see: http://live.gnome.org/GnomeLove/DragNDropTutorial + + Gtk.drag_source_set ( + this.el, /* widget will be drag-able */ + Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */ + BuilderApplication.targetList, /* lists of target to support */ + Gdk.DragAction.COPY /* what to do with data after dropped */ + ); + //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList); + + // Gtk.drag_source_set_target_list(this.el, Application.targetList); + // Gtk.drag_source_add_text_targets(this.el); + + } + + //listeners + this.el.button_press_event.connect( ( event) => { + + // if (!this.get('/Editor').save()) { + // // popup!! - click handled.. + // return true; + // } + return false; + }); + this.el.drag_begin.connect( ( ctx) => { + // we could fill this in now... + // Seed.print('SOURCE: drag-begin'); + + + + Gtk.TreeIter iter; + var s = this.el.get_selection(); + + Gtk.TreeModel mod; + s.get_selected(out mod, out iter); + var path = mod.get_path(iter); + + /// pix is a surface.. + var pix = this.el.create_row_drag_icon ( path); + + + Gtk.drag_set_icon_surface (ctx, pix); + GLib.Value value; + + + _this.model.el.get_value(iter, 0, out value); + + this.dragData = (string) value; + + + return; + }); + this.el.drag_data_get.connect( (drag_context, selection_data, info, time) => { + //Seed.print('Palete: drag-data-get: ' + target_type); + if (this.dragData.length < 1 ) { + return; + } + + GLib.debug("setting drag data to %s\n", this.dragData); + // selection_data.set_text(this.dragData ,this.dragData.length); + selection_data.set (selection_data.get_target (), 8, (uchar[]) this.dragData.to_utf8 ()); + + //this.el.dragData = "TEST from source widget"; + + + }); + this.el.drag_end.connect( ( drag_context) => { + GLib.debug("SOURCE: drag-end (call listener on this)\n"); + + this.dragData = ""; + //this.dropList = null; + _this.drag_end(); // call signal.. + //this.get('/LeftTree.view').highlight(false); + + }); + } + + // user defined functions + } + public class Xcls_model : Object + { + public Gtk.ListStore el; + private Xcls_PopoverAddObject _this; + + + // my vars (def) + + // ctor + public Xcls_model(Xcls_PopoverAddObject _owner ) + { + _this = _owner; + _this.model = this; + this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + public string getValue (Gtk.TreeIter iter, int col) { + GLib.Value gval; + this.el.get_value(iter, col , out gval); + return (string)gval; + + } + } + + public class Xcls_TreeViewColumn5 : Object + { + public Gtk.TreeViewColumn el; + private Xcls_PopoverAddObject _this; + + + // my vars (def) + + // ctor + public Xcls_TreeViewColumn5(Xcls_PopoverAddObject _owner ) + { + _this = _owner; + this.el = new Gtk.TreeViewColumn(); + + // my vars (dec) + + // set gobject values + this.el.title = "Drag to add Object"; + var child_0 = new Xcls_txtrender( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , true ); + + // init method + + this.el.add_attribute(_this.txtrender.el , "markup", 1 ); + } + + // user defined functions + } + public class Xcls_txtrender : Object + { + public Gtk.CellRendererText el; + private Xcls_PopoverAddObject _this; + + + // my vars (def) + + // ctor + public Xcls_txtrender(Xcls_PopoverAddObject _owner ) + { + _this = _owner; + _this.txtrender = this; + this.el = new Gtk.CellRendererText(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + + + +} diff --git a/src/Builder4/PopoverAddProp.bjs b/src/Builder4/PopoverAddProp.bjs new file mode 100644 index 000000000..ba3738a61 --- /dev/null +++ b/src/Builder4/PopoverAddProp.bjs @@ -0,0 +1,224 @@ +{ + "build_module" : "", + "items" : [ + { + "$ xns" : "Gtk", + "@ void select" : "(string key, string type, string skel, string prop_or_listener)", + "Gtk.PositionType position" : "Gtk.PositionType.RIGHT", + "Xcls_MainWindow mainwindow" : "", + "bool active" : false, + "bool hexpand" : false, + "bool modal" : true, + "id" : "PopoverAddProp", + "int height_request" : 800, + "int width_request" : 900, + "items" : [ + { + "$ shadow_type" : "Gtk.ShadowType.IN", + "$ xns" : "Gtk", + "* init" : [ + " this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);", + " " + ], + "* pack" : "add", + "items" : [ + { + "$ enable_tree_lines" : true, + "$ headers_visible" : true, + "$ xns" : "Gtk", + "* init" : [ + "{ ", + " var description = new Pango.FontDescription();", + " description.set_size(10000);", + " this.el.override_font(description); ", + " ", + " this.el.get_selection().set_mode( Gtk.SelectionMode.SINGLE);", + " ", + "", + " ", + " ", + " ", + "}", + "" + ], + "* pack" : "add", + "items" : [ + { + "$ columns" : [ + "typeof(string), // 0 real key", + "typeof(string), // 1 real type", + "typeof(string), // 2 docs ?", + "typeof(string), // 3 visable desc", + "typeof(string), // 4 function desc", + "typeof(string) // 5 element type (event|prop)", + " " + ], + "$ xns" : "Gtk", + "* pack" : "set_model", + "id" : "model", + "n_columns" : 6, + "xtype" : "ListStore", + "| string getValue" : [ + "(Gtk.TreeIter iter, int col)", + "{", + "", + " GLib.Value value;", + " this.el.get_value(iter, col, out value);", + " ", + " return (string)value;", + " ", + "}" + ] + }, + { + "$ xns" : "Gtk", + "* init" : [ + " this.el.add_attribute(_this.namerender.el , \"markup\", 4 );", + " ", + "" + ], + "* pack" : "append_column", + "id" : "namecol", + "items" : [ + { + "$ xns" : "Gtk", + "* pack" : "pack_start,true", + "id" : "namerender", + "xtype" : "CellRendererText" + } + ], + "utf8 title" : "Double click to add", + "xtype" : "TreeViewColumn" + } + ], + "listeners" : { + "row_activated" : [ + "(path, column) => {", + "", + "\tGtk.TreeIter iter;", + "", + "", + "\tvar m = _this.model;", + "", + "\tm.el.get_iter(out iter,path);", + "", + "", + "\t// var val = \"\";", + "", + "", + "\tvar key = m.getValue(iter, 0);", + "", + "\tvar type = m.getValue(iter, 1);", + "\tvar skel = m.getValue(iter, 3);", + "\tvar etype = m.getValue(iter, 5);", + "", + "\t// hide the popover", + "\t_this.el.hide();", + "\t_this.prop_or_listener = \"\";", + "\t", + "\t", + "\t_this.select(key,etype == \"signals\" ? \"\" : type,skel, etype);", + " ", + "}", + " " + ] + }, + "tooltip_column" : 2, + "xtype" : "TreeView" + } + ], + "xtype" : "ScrolledWindow" + } + ], + "string prop_or_listener" : "\"\"", + "xtype" : "Popover", + "| void clear" : [ + "() {", + " this.model.el.clear();", + "}", + "" + ], + "| void hide" : [ + "() {", + "\tthis.prop_or_listener = \"\";", + "\tthis.el.hide();", + "}", + "" + ], + "| void show" : [ + "(Palete.Palete pal, string prop_or_listener, string xtype, Gtk.Widget onbtn) {", + "", + " ", + " if (this.prop_or_listener != \"\" && this.prop_or_listener == prop_or_listener) {", + " \tthis.prop_or_listener = \"\";", + " \tthis.el.hide();", + " \treturn;", + "\t}", + " this.prop_or_listener = prop_or_listener;", + " ", + " this.model.el.clear();", + "", + " Gtk.TreeIter iter;", + " var elementList = pal.getPropertiesFor( xtype,prop_or_listener);", + " ", + " //print (\"GOT \" + elementList.length + \" items for \" + fullpath + \"|\" + type);", + " // console.dump(elementList);", + " ", + " var miter = elementList.map_iterator();", + " while (miter.next()) {", + " var p = miter.get_value();", + " ", + " this.model.el.append(out iter);", + "", + "\t\tvar dname = p.name;", + "\t\tvar dtype = p.type;", + "\t\t ", + "", + " this.model.el.set(iter,", + " 0, p.name, ", + " 1, p.type,", + " 2, \"\" + p.name +\" \"+p.type+\"\\n\" + ", + " GLib.Markup.escape_text(p.doctxt),", + " 3, p.sig,", + " 4, \"\" + dname +\" \"+dtype+\"\",", + " 5, prop_or_listener,", + " -1", + " );", + " }", + " this.model.el.set_sort_column_id(0,Gtk.SortType.ASCENDING); ", + " ", + " // set size up...", + " ", + "", + " int w,h;", + " this.mainwindow.el.get_size(out w, out h);", + " ", + " // left tree = 250, editor area = 500?", + " ", + " // min 450?", + "\t// max hieght ...", + " this.el.set_size_request( 250, h);", + "", + " ", + "", + " if (this.el.relative_to == null) {", + " this.el.set_relative_to(onbtn);", + " }", + " this.el.show_all();", + " ", + " while(Gtk.events_pending()) { ", + " Gtk.main_iteration(); // why?", + " } ", + " // this.hpane.el.set_position( 0);", + "}", + "" + ] + } + ], + "modOrder" : "", + "name" : "PopoverAddProp", + "parent" : "", + "path" : "/home/alan/gitlive/roobuilder/src/Builder4/PopoverAddProp.bjs", + "permname" : "", + "title" : "" +} \ No newline at end of file diff --git a/src/Builder4/PopoverAddProp.vala b/src/Builder4/PopoverAddProp.vala new file mode 100644 index 000000000..07b1a3fa0 --- /dev/null +++ b/src/Builder4/PopoverAddProp.vala @@ -0,0 +1,316 @@ +static Xcls_PopoverAddProp _PopoverAddProp; + +public class Xcls_PopoverAddProp : Object +{ + public Gtk.Popover el; + private Xcls_PopoverAddProp _this; + + public static Xcls_PopoverAddProp singleton() + { + if (_PopoverAddProp == null) { + _PopoverAddProp= new Xcls_PopoverAddProp(); + } + return _PopoverAddProp; + } + public Xcls_model model; + public Xcls_namecol namecol; + public Xcls_namerender namerender; + + // my vars (def) + public bool active; + public signal void select (string key, string type, string skel, string prop_or_listener); + public Xcls_MainWindow mainwindow; + public string prop_or_listener; + + // ctor + public Xcls_PopoverAddProp() + { + _this = this; + this.el = new Gtk.Popover( null ); + + // my vars (dec) + this.active = false; + this.prop_or_listener = ""; + + // set gobject values + this.el.width_request = 900; + this.el.height_request = 800; + this.el.hexpand = false; + this.el.modal = true; + this.el.position = Gtk.PositionType.RIGHT; + var child_0 = new Xcls_ScrolledWindow2( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + } + + // user defined functions + public void show (Palete.Palete pal, string prop_or_listener, string xtype, Gtk.Widget onbtn) { + + + if (this.prop_or_listener != "" && this.prop_or_listener == prop_or_listener) { + this.prop_or_listener = ""; + this.el.hide(); + return; + } + this.prop_or_listener = prop_or_listener; + + this.model.el.clear(); + + Gtk.TreeIter iter; + var elementList = pal.getPropertiesFor( xtype,prop_or_listener); + + //print ("GOT " + elementList.length + " items for " + fullpath + "|" + type); + // console.dump(elementList); + + var miter = elementList.map_iterator(); + while (miter.next()) { + var p = miter.get_value(); + + this.model.el.append(out iter); + + var dname = p.name; + var dtype = p.type; + + + this.model.el.set(iter, + 0, p.name, + 1, p.type, + 2, "" + p.name +" "+p.type+"\n" + + GLib.Markup.escape_text(p.doctxt), + 3, p.sig, + 4, "" + dname +" "+dtype+"", + 5, prop_or_listener, + -1 + ); + } + this.model.el.set_sort_column_id(0,Gtk.SortType.ASCENDING); + + // set size up... + + + int w,h; + this.mainwindow.el.get_size(out w, out h); + + // left tree = 250, editor area = 500? + + // min 450? + // max hieght ... + this.el.set_size_request( 250, h); + + + + if (this.el.relative_to == null) { + this.el.set_relative_to(onbtn); + } + this.el.show_all(); + + while(Gtk.events_pending()) { + Gtk.main_iteration(); // why? + } + // this.hpane.el.set_position( 0); + } + public void hide () { + this.prop_or_listener = ""; + this.el.hide(); + } + public void clear () { + this.model.el.clear(); + } + public class Xcls_ScrolledWindow2 : Object + { + public Gtk.ScrolledWindow el; + private Xcls_PopoverAddProp _this; + + + // my vars (def) + + // ctor + public Xcls_ScrolledWindow2(Xcls_PopoverAddProp _owner ) + { + _this = _owner; + this.el = new Gtk.ScrolledWindow( null, null ); + + // my vars (dec) + + // set gobject values + this.el.shadow_type = Gtk.ShadowType.IN; + var child_0 = new Xcls_TreeView3( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + + // init method + + this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); + } + + // user defined functions + } + public class Xcls_TreeView3 : Object + { + public Gtk.TreeView el; + private Xcls_PopoverAddProp _this; + + + // my vars (def) + + // ctor + public Xcls_TreeView3(Xcls_PopoverAddProp _owner ) + { + _this = _owner; + this.el = new Gtk.TreeView(); + + // my vars (dec) + + // set gobject values + this.el.tooltip_column = 2; + this.el.enable_tree_lines = true; + this.el.headers_visible = true; + var child_0 = new Xcls_model( _this ); + child_0.ref(); + this.el.set_model ( child_0.el ); + var child_1 = new Xcls_namecol( _this ); + child_1.ref(); + this.el.append_column ( child_1.el ); + + // init method + + { + var description = new Pango.FontDescription(); + description.set_size(10000); + this.el.override_font(description); + + this.el.get_selection().set_mode( Gtk.SelectionMode.SINGLE); + + + + + + } + + //listeners + this.el.row_activated.connect( (path, column) => { + + Gtk.TreeIter iter; + + + var m = _this.model; + + m.el.get_iter(out iter,path); + + + // var val = ""; + + + var key = m.getValue(iter, 0); + + var type = m.getValue(iter, 1); + var skel = m.getValue(iter, 3); + var etype = m.getValue(iter, 5); + + // hide the popover + _this.el.hide(); + _this.prop_or_listener = ""; + + + _this.select(key,etype == "signals" ? "" : type,skel, etype); + + }); + } + + // user defined functions + } + public class Xcls_model : Object + { + public Gtk.ListStore el; + private Xcls_PopoverAddProp _this; + + + // my vars (def) + + // ctor + public Xcls_model(Xcls_PopoverAddProp _owner ) + { + _this = _owner; + _this.model = this; + this.el = new Gtk.ListStore( 6, typeof(string), // 0 real key +typeof(string), // 1 real type +typeof(string), // 2 docs ? +typeof(string), // 3 visable desc +typeof(string), // 4 function desc +typeof(string) // 5 element type (event|prop) + ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + public string getValue (Gtk.TreeIter iter, int col) + { + + GLib.Value value; + this.el.get_value(iter, col, out value); + + return (string)value; + + } + } + + public class Xcls_namecol : Object + { + public Gtk.TreeViewColumn el; + private Xcls_PopoverAddProp _this; + + + // my vars (def) + + // ctor + public Xcls_namecol(Xcls_PopoverAddProp _owner ) + { + _this = _owner; + _this.namecol = this; + this.el = new Gtk.TreeViewColumn(); + + // my vars (dec) + + // set gobject values + this.el.title = "Double click to add"; + var child_0 = new Xcls_namerender( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , true ); + + // init method + + this.el.add_attribute(_this.namerender.el , "markup", 4 ); + } + + // user defined functions + } + public class Xcls_namerender : Object + { + public Gtk.CellRendererText el; + private Xcls_PopoverAddProp _this; + + + // my vars (def) + + // ctor + public Xcls_namerender(Xcls_PopoverAddProp _owner ) + { + _this = _owner; + _this.namerender = this; + this.el = new Gtk.CellRendererText(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + + + +} diff --git a/src/Builder4/PopoverEditor.bjs b/src/Builder4/PopoverEditor.bjs new file mode 100644 index 000000000..4123f43a7 --- /dev/null +++ b/src/Builder4/PopoverEditor.bjs @@ -0,0 +1,81 @@ +{ + "build_module" : "", + "items" : [ + { + "# Editor editor" : "", + "$ xns" : "Gtk", + "* init" : [ + "{", + " this.editor = new Editor();", + " this.el.add(this.editor.el);", + "}", + "" + ], + "Gtk.PositionType position" : "Gtk.PositionType.RIGHT", + "Xcls_MainWindow win" : "", + "bool active" : false, + "bool hexpand" : false, + "bool modal" : true, + "id" : "PopoverEditor", + "int height_request" : 800, + "int width_request" : 900, + "listeners" : { + "hide" : [ + "() => {", + "\t// save...", + "\t _this.editor.saveContents();", + "}" + ] + }, + "string prop_or_listener" : "\"\"", + "xtype" : "Popover", + "| void setMainWindow" : [ + "(Xcls_MainWindow win) {", + "\tthis.win = win;", + "\tthis.editor.window = win;", + "}", + "" + ], + "| void show" : [ + "(Gtk.Widget on_el, JsRender.JsRender file, JsRender.Node? node, string ptype, string key) {", + "\tthis.editor.show( file, node, ptype, key);", + "\t", + " int w,h;", + " this.win.el.get_size(out w, out h);", + " ", + " // left tree = 250, editor area = 500?", + " ", + " // min 450?", + "\t// max hieght ...", + "\t", + "\tvar ww = on_el.get_allocated_width();", + "\t", + "\t// width = should be max = w-ww , or 600 at best..?", + "\t ", + " this.el.set_size_request( int.min(800,(w - ww)), h);", + "", + " ", + "\tthis.el.set_modal(true);", + "\tthis.el.set_relative_to(on_el);", + "", + "\tthis.el.set_position(Gtk.PositionType.TOP);", + "", + "\t// window + header?", + " ", + "\tthis.el.show_all();", + " //while(Gtk.events_pending()) { ", + " // Gtk.main_iteration(); // why?", + " //} ", + "", + "}", + "" + ] + } + ], + "modOrder" : "", + "name" : "PopoverEditor", + "parent" : "", + "path" : "/home/alan/gitlive/roobuilder/src/Builder4/PopoverEditor.bjs", + "permname" : "", + "title" : "" +} \ No newline at end of file diff --git a/src/Builder4/PopoverEditor.vala b/src/Builder4/PopoverEditor.vala new file mode 100644 index 000000000..b1c40e057 --- /dev/null +++ b/src/Builder4/PopoverEditor.vala @@ -0,0 +1,89 @@ +static Xcls_PopoverEditor _PopoverEditor; + +public class Xcls_PopoverEditor : Object +{ + public Gtk.Popover el; + private Xcls_PopoverEditor _this; + + public static Xcls_PopoverEditor singleton() + { + if (_PopoverEditor == null) { + _PopoverEditor= new Xcls_PopoverEditor(); + } + return _PopoverEditor; + } + + // my vars (def) + public bool active; + public Editor editor; + public Xcls_MainWindow win; + public string prop_or_listener; + + // ctor + public Xcls_PopoverEditor() + { + _this = this; + this.el = new Gtk.Popover( null ); + + // my vars (dec) + this.active = false; + this.prop_or_listener = ""; + + // set gobject values + this.el.width_request = 900; + this.el.height_request = 800; + this.el.hexpand = false; + this.el.modal = true; + this.el.position = Gtk.PositionType.RIGHT; + + // init method + + { + this.editor = new Editor(); + this.el.add(this.editor.el); + } + + //listeners + this.el.hide.connect( () => { + // save... + _this.editor.saveContents(); + }); + } + + // user defined functions + public void show (Gtk.Widget on_el, JsRender.JsRender file, JsRender.Node? node, string ptype, string key) { + this.editor.show( file, node, ptype, key); + + int w,h; + this.win.el.get_size(out w, out h); + + // left tree = 250, editor area = 500? + + // min 450? + // max hieght ... + + var ww = on_el.get_allocated_width(); + + // width = should be max = w-ww , or 600 at best..? + + this.el.set_size_request( int.min(800,(w - ww)), h); + + + this.el.set_modal(true); + this.el.set_relative_to(on_el); + + this.el.set_position(Gtk.PositionType.TOP); + + // window + header? + + this.el.show_all(); + //while(Gtk.events_pending()) { + // Gtk.main_iteration(); // why? + //} + + } + public void setMainWindow (Xcls_MainWindow win) { + this.win = win; + this.editor.window = win; + } +} diff --git a/src/Builder4/PopoverFileDetails.bjs b/src/Builder4/PopoverFileDetails.bjs index a9bcb765f..534bfc536 100644 --- a/src/Builder4/PopoverFileDetails.bjs +++ b/src/Builder4/PopoverFileDetails.bjs @@ -1,297 +1,733 @@ { - "name" : "PopoverFileDetails", - "parent" : "", - "title" : "", - "path" : "/home/alan/gitlive/roobuilder/src/Builder4/PopoverFileDetails.bjs", - "permname" : "", - "modOrder" : "", "build_module" : "builder", "items" : [ { - "listeners" : { - "closed" : "() => {\n if (!this.done) {\n _this.el.show();\n \n }\n} " - }, - "| void updateFileFromEntry" : "() {\n\n _this.file.title = _this.title.el.get_text();\n _this.file.region = _this.region.el.get_text(); \n _this.file.parent = _this.parent.el.get_text(); \n _this.file.permname = _this.permname.el.get_text(); \n _this.file.modOrder = _this.modOrder.el.get_text();\n \n if (_this.file.name.length > 0 && _this.file.name != _this.name.el.get_text()) {\n _this.file.renameTo(_this.name.el.get_text());\n }\n // store the module...\n _this.file.build_module = \"\"; \n Gtk.TreeIter iter; \n if (_this.build_module.el.get_active_iter (out iter)) {\n Value vfname;\n this.dbmodel.el.get_value (iter, 0, out vfname);\n if (((string)vfname).length > 0) {\n _this.file.build_module = (string)vfname;\n }\n \n }\n \n \n\n \n} ", - "id" : "PopoverFileDetails", - "@ void success" : "(Project.Project pr, JsRender.JsRender file)", - "| void show" : "(JsRender.JsRender c, Gtk.Widget btn) \n{\n this.project = c.project;\n this.done = false;\n \n \n //if (!this.el) {\n //this.init();\n //}\n \n _this.name.el.set_text(c.name);\n _this.title.el.set_text(c.title);\n _this.parent.el.set_text(c.parent); \n _this.region.el.set_text(c.region);\n _this.modOrder.el.set_text(c.modOrder);\n _this.permname.el.set_text(c.permname);\n \n \n \n \n \n \n \n \n var ar = new Gee.ArrayList();\n _this.dbmodel.loadData(ar,\"\");\n // load the modules... if relivant..\n if (this.project.xtype == \"Gtk\") {\n var p = (Project.Gtk)c.project;\n var cg = p.compilegroups;\n\n var iter = cg.map_iterator();\n while(iter.next()) {\n var key = iter.get_key();\n if (key == \"_default_\") {\n continue;\n }\n ar.add(key);\n };\n _this.dbmodel.loadData(ar, c.build_module);\n\n }\n \n \n _this.file = c;\n //console.log('show all');\n this.el.set_modal(true);\n this.el.set_relative_to(btn);\n\n this.el.set_position(Gtk.PositionType.RIGHT);\n \n // window + header?\n print(\"SHOWALL - POPIP\\n\");\n this.el.show_all();\n this.name.el.grab_focus();\n \n \n \n if (c.path.length > 0) {\n\t this.save_btn.el.set_label(\"Save\");\n\t\t_this.filetype.el.hide();\n\t\t_this.filetypelbl.el.hide();\n\t\t_this.filetype.showhide(true); // as we only work on bjs files currently\n } else {\n this.save_btn.el.set_label(\"Create\");\n _this.ftdbmodel.loadData(\"bjs\"); // fixme - need to determine type..\n\t _this.filetype.el.show();\n\t _this.filetypelbl.el.show();\n }\n \n \n //this.success = c.success;\n \n \n}", - "bool done" : false, - "# Project.Project project" : "", - "xtype" : "Popover", - "Gtk.PositionType position" : "Gtk.PositionType.RIGHT", "# JsRender.JsRender file" : "null", + "# Project.Project project" : "", "$ xns" : "Gtk", + "@ void success" : "(Project.Project pr, JsRender.JsRender file)", + "Gtk.PositionType position" : "Gtk.PositionType.RIGHT", "Xcls_MainWindow mainwindow" : "null", + "bool done" : false, "bool modal" : true, - "uint border_width" : 0, + "id" : "PopoverFileDetails", "items" : [ { - "bool homogeneous" : false, "$ pack" : "add", - "xtype" : "Box", "$ xns" : "Gtk", "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", + "bool homogeneous" : false, "items" : [ { - "* pack" : "pack_start,false,true,0", - "xtype" : "HeaderBar", "$ xns" : "Gtk", - "string title" : "Add / Edit File" + "* pack" : "pack_start,false,true,0", + "string title" : "Add / Edit File", + "xtype" : "HeaderBar" }, { - "id" : "grid", - "int margin_right" : 4, - "* pack" : "pack_start,false,false,4", - "xtype" : "Grid", - "uint row_spacing" : 2, - "n_columns" : 2, - "$ xns" : "Gtk", - "n_rows" : 7, "$ homogeneous" : true, + "$ xns" : "Gtk", + "* pack" : "pack_start,false,false,4", + "id" : "grid", "int margin_left" : 4, + "int margin_right" : 4, "items" : [ { - "label" : "File type", - "id" : "filetypelbl", - "xalign" : 0.90000000000000002, - "* pack" : "attach,0,0,1,1", - "xtype" : "Label", "$ justify" : "Gtk.Justification.RIGHT", + "$ xns" : "Gtk", + "* pack" : "attach,0,0,1,1", + "id" : "filetypelbl", + "label" : "File type", "x_options" : 4, - "$ xns" : "Gtk" + "xalign" : 0.90000000000000002, + "xtype" : "Label" }, { - "listeners" : { - "changed" : "() => {\n\tGtk.TreeIter iter;\n\tbool is_bjs = true;\n\tif (this.el.get_active_iter(out iter)) {\n\t\tValue vfname;\n\t\t_this.ftdbmodel.el.get_value (iter, 0, out vfname);\n\t\t is_bjs = ((string)vfname) == \"bjs\";\n\t}\n \n \n // directory is only available for non-bjs \n this.showhide(is_bjs);\n\n\n}\n" - }, - "id" : "filetype", + "$ xns" : "Gtk", "* init" : "this.el.add_attribute(_this.ftdbcellrenderer.el , \"markup\", 1 );", "* pack" : "attach,1,0,1,1", - "xtype" : "ComboBox", - "| void showhide" : "(bool is_bjs) {\n\n\n\tif (_this.project.xtype != \"Roo\") {\n\t \tis_bjs = false;\n \t}\n\n\tfor (var i = 2; i < 9;i++) {\n\t\tvar el = _this.grid.el.get_child_at(0,i);\n\t\t\n\t\tvar showhide= is_bjs;\n\t\tif (i> 7) {\n\t\t\tshowhide = !showhide;\n\t\t}\n\t\t\n\t\tif (showhide) {\n\t\t el.show();\n\t\t} else {\n\t\t\tel.hide();\n\t\t}\n\t\t el = _this.grid.el.get_child_at(1,i);\n\t\tif (showhide) {\n\t\t el.show();\n\t\t} else {\n\t\t\tel.hide();\n\t\t} \n }\n // load up the directories\n //??? why can we not create bjs files in other directories??\n\t//if (!is_bjs && _this.file.path.length < 1) {\n\t\n\t\t_this.dirmodel.loadData();\n\t\t\n\t\t\n\t//}\n \n \n}\n", - "$ xns" : "Gtk", + "id" : "filetype", "items" : [ { - "id" : "ftdbcellrenderer", - "xtype" : "CellRendererText", + "$ xns" : "Gtk", "* pack" : "pack_start,true", - "$ xns" : "Gtk" + "id" : "ftdbcellrenderer", + "xtype" : "CellRendererText" }, { - "id" : "ftdbmodel", - "xtype" : "ListStore", - "* pack" : "set_model", "$ columns" : "typeof(string),typeof(string)", - "n_columns" : 2, "$ xns" : "Gtk", - "| void loadData" : " (string cur) {\n this.el.clear(); \n Gtk.TreeIter iter;\n var el = this.el;\n \n /// el.append(out iter);\n \n \n // el.set_value(iter, 0, \"\");\n // el.set_value(iter, 1, \"aaa - Just add Element - aaa\");\n\n el.append(out iter);\n\n \n el.set_value(iter, 0, \"bjs\");\n el.set_value(iter, 1, \"User Interface File (bjs)\");\n _this.filetype.el.set_active_iter(iter);\n\n el.append(out iter);\n \n el.set_value(iter, 0, \"vala\");\n el.set_value(iter, 1, \"Vala\");\n\tif (cur == \"vala\") {\n\t _this.filetype.el.set_active_iter(iter);\n }\n\n\n\n el.append(out iter);\n \n el.set_value(iter, 0, \"js\");\n el.set_value(iter, 1, \"Javascript\");\n\n\tif (cur == \"js\") {\n\t _this.filetype.el.set_active_iter(iter);\n }\n\n el.append(out iter);\n \n el.set_value(iter, 0, \"css\");\n el.set_value(iter, 1, \"CSS\");\n\n\tif (cur == \"css\") {\n\t _this.filetype.el.set_active_iter(iter);\n }\n \n}\n" + "* pack" : "set_model", + "id" : "ftdbmodel", + "n_columns" : 2, + "xtype" : "ListStore", + "| void loadData" : [ + " (string cur) {", + " this.el.clear(); ", + " Gtk.TreeIter iter;", + " var el = this.el;", + " ", + " /// el.append(out iter);", + " ", + " ", + " // el.set_value(iter, 0, \"\");", + " // el.set_value(iter, 1, \"aaa - Just add Element - aaa\");", + "", + " el.append(out iter);", + "", + " ", + " el.set_value(iter, 0, \"bjs\");", + " el.set_value(iter, 1, \"User Interface File (bjs)\");", + " _this.filetype.el.set_active_iter(iter);", + "", + " el.append(out iter);", + " ", + " el.set_value(iter, 0, \"vala\");", + " el.set_value(iter, 1, \"Vala\");", + "\tif (cur == \"vala\") {", + "\t _this.filetype.el.set_active_iter(iter);", + " }", + "", + "", + "", + " el.append(out iter);", + " ", + " el.set_value(iter, 0, \"js\");", + " el.set_value(iter, 1, \"Javascript\");", + "", + "\tif (cur == \"js\") {", + "\t _this.filetype.el.set_active_iter(iter);", + " }", + "", + " el.append(out iter);", + " ", + " el.set_value(iter, 0, \"css\");", + " el.set_value(iter, 1, \"CSS\");", + "", + "\tif (cur == \"css\") {", + "\t _this.filetype.el.set_active_iter(iter);", + " }", + " ", + "}", + "" + ] } + ], + "listeners" : { + "changed" : [ + "() => {", + "\tGtk.TreeIter iter;", + "\tbool is_bjs = true;", + "\tif (this.el.get_active_iter(out iter)) {", + "\t\tValue vfname;", + "\t\t_this.ftdbmodel.el.get_value (iter, 0, out vfname);", + "\t\t is_bjs = ((string)vfname) == \"bjs\";", + "\t}", + " ", + " ", + " // directory is only available for non-bjs ", + " this.showhide(is_bjs);", + "", + "", + "}", + "" + ] + }, + "xtype" : "ComboBox", + "| void showhide" : [ + "(bool is_bjs) {", + "", + "", + "\tif (_this.project.xtype != \"Roo\") {", + "\t \tis_bjs = false;", + " \t}", + "", + "\tfor (var i = 2; i < 9;i++) {", + "\t\tvar el = _this.grid.el.get_child_at(0,i);", + "\t\t", + "\t\tvar showhide= is_bjs;", + "\t\tif (i> 7) {", + "\t\t\tshowhide = !showhide;", + "\t\t}", + "\t\t", + "\t\tif (showhide) {", + "\t\t el.show();", + "\t\t} else {", + "\t\t\tel.hide();", + "\t\t}", + "\t\t el = _this.grid.el.get_child_at(1,i);", + "\t\tif (showhide) {", + "\t\t el.show();", + "\t\t} else {", + "\t\t\tel.hide();", + "\t\t} ", + " }", + " // load up the directories", + " //??? why can we not create bjs files in other directories??", + "\t//if (!is_bjs && _this.file.path.length < 1) {", + "\t", + "\t\t_this.dirmodel.loadData();", + "\t\t", + "\t\t", + "\t//}", + " ", + " ", + "}", + "" ] }, { - "label" : "Component Name", - "xalign" : 0.90000000000000002, - "* pack" : "attach,0,1,1,1", - "xtype" : "Label", "$ justify" : "Gtk.Justification.RIGHT", + "$ xns" : "Gtk", + "* pack" : "attach,0,1,1,1", + "label" : "Component Name", "x_options" : 4, - "$ xns" : "Gtk" + "xalign" : 0.90000000000000002, + "xtype" : "Label" }, { - "id" : "name", "$ visible" : true, - "xtype" : "Entry", + "$ xns" : "Gtk", "* pack" : "attach,1,1,1,1", - "$ xns" : "Gtk" + "id" : "name", + "xtype" : "Entry" }, { - "label" : "Title", + "$ justify" : "Gtk.Justification.RIGHT", "$ visible" : true, - "xalign" : 0.90000000000000002, + "$ xns" : "Gtk", "* pack" : "attach,0,2,1,1", - "xtype" : "Label", - "$ justify" : "Gtk.Justification.RIGHT", + "label" : "Title", "x_options" : 4, - "$ xns" : "Gtk" + "xalign" : 0.90000000000000002, + "xtype" : "Label" }, { - "id" : "title", "$ visible" : true, - "xtype" : "Entry", + "$ xns" : "Gtk", "* pack" : "attach,1,2,1,1", - "$ xns" : "Gtk" + "id" : "title", + "xtype" : "Entry" }, { - "label" : "Region", - "tooltip_text" : "center, north, south, east, west", + "$ justify" : "Gtk.Justification.RIGHT", "$ visible" : true, - "xalign" : 0.90000000000000002, + "$ xns" : "Gtk", "* pack" : "attach,0,3,1,1", - "xtype" : "Label", - "$ justify" : "Gtk.Justification.RIGHT", + "label" : "Region", + "tooltip_text" : "center, north, south, east, west", "x_options" : 4, - "$ xns" : "Gtk" + "xalign" : 0.90000000000000002, + "xtype" : "Label" }, { - "id" : "region", "$ visible" : true, - "xtype" : "Entry", + "$ xns" : "Gtk", "* pack" : "attach,1,3,1,1", - "$ xns" : "Gtk" + "id" : "region", + "xtype" : "Entry" }, { - "label" : "Parent Name", + "$ justify" : "Gtk.Justification.RIGHT", "$ visible" : true, - "xalign" : 0.90000000000000002, + "$ xns" : "Gtk", "* pack" : "attach,0,4,1,1", - "xtype" : "Label", - "$ justify" : "Gtk.Justification.RIGHT", + "label" : "Parent Name", "x_options" : 4, - "$ xns" : "Gtk" + "xalign" : 0.90000000000000002, + "xtype" : "Label" }, { - "id" : "parent", "$ visible" : true, - "xtype" : "Entry", + "$ xns" : "Gtk", "* pack" : "attach,1,4,1,1", - "$ xns" : "Gtk" + "id" : "parent", + "xtype" : "Entry" }, { - "label" : "Permission Name", + "$ justify" : "Gtk.Justification.RIGHT", "$ visible" : true, - "xalign" : 0.90000000000000002, + "$ xns" : "Gtk", "* pack" : "attach,0,5,1,1", - "xtype" : "Label", - "$ justify" : "Gtk.Justification.RIGHT", + "label" : "Permission Name", "x_options" : 4, - "$ xns" : "Gtk" + "xalign" : 0.90000000000000002, + "xtype" : "Label" }, { - "id" : "permname", "$ visible" : true, - "xtype" : "Entry", + "$ xns" : "Gtk", "* pack" : "attach,1,5,1,1", - "$ xns" : "Gtk" + "id" : "permname", + "xtype" : "Entry" }, { - "label" : "Order (for tabs)", + "$ justify" : "Gtk.Justification.RIGHT", "$ visible" : true, - "xalign" : 0.90000000000000002, + "$ xns" : "Gtk", "* pack" : "attach,0,6,1,1", - "xtype" : "Label", - "$ justify" : "Gtk.Justification.RIGHT", + "label" : "Order (for tabs)", "x_options" : 4, - "$ xns" : "Gtk" + "xalign" : 0.90000000000000002, + "xtype" : "Label" }, { - "id" : "modOrder", "$ visible" : true, - "xtype" : "Entry", + "$ xns" : "Gtk", "* pack" : "attach,1,6,1,1", - "$ xns" : "Gtk" + "id" : "modOrder", + "xtype" : "Entry" }, { - "label" : "Module to build (Vala only)", + "$ justify" : "Gtk.Justification.RIGHT", "$ visible" : true, - "xalign" : 0.90000000000000002, + "$ xns" : "Gtk", "* pack" : "attach,0,7,1,1", - "xtype" : "Label", - "$ justify" : "Gtk.Justification.RIGHT", + "label" : "Module to build (Vala only)", "x_options" : 4, - "$ xns" : "Gtk" + "xalign" : 0.90000000000000002, + "xtype" : "Label" }, { - "id" : "build_module", + "$ xns" : "Gtk", "* init" : "this.el.add_attribute(_this.dbcellrenderer.el , \"markup\", 1 );", "* pack" : "attach,1,7,1,1", - "xtype" : "ComboBox", - "$ xns" : "Gtk", + "id" : "build_module", "items" : [ { - "id" : "dbcellrenderer", + "$ xns" : "Gtk", "* pack" : "pack_start,true", - "xtype" : "CellRendererText", - "$ xns" : "Gtk" + "id" : "dbcellrenderer", + "xtype" : "CellRendererText" }, { - "id" : "dbmodel", - "* pack" : "set_model", - "xtype" : "ListStore", "$ columns" : "typeof(string),typeof(string)", - "n_columns" : 2, "$ xns" : "Gtk", - "| void loadData" : " (Gee.ArrayList data, string cur) {\n this.el.clear(); \n Gtk.TreeIter iter;\n var el = this.el;\n \n /// el.append(out iter);\n \n \n // el.set_value(iter, 0, \"\");\n // el.set_value(iter, 1, \"aaa - Just add Element - aaa\");\n\n el.append(out iter);\n\n \n el.set_value(iter, 0, \"\");\n el.set_value(iter, 1, \"-- select a module --\");\n _this.build_module.el.set_active_iter(iter);\n \n for (var i = 0; i < data.size;i++) {\n \n\n el.append(out iter);\n \n el.set_value(iter, 0, data.get(i));\n el.set_value(iter, 1, data.get(i));\n \n if (data.get(i) == cur) {\n _this.build_module.el.set_active_iter(iter);\n }\n \n }\n this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING); \n \n}\n" + "* pack" : "set_model", + "id" : "dbmodel", + "n_columns" : 2, + "xtype" : "ListStore", + "| void loadData" : [ + " (Gee.ArrayList data, string cur) {", + " this.el.clear(); ", + " Gtk.TreeIter iter;", + " var el = this.el;", + " ", + " /// el.append(out iter);", + " ", + " ", + " // el.set_value(iter, 0, \"\");", + " // el.set_value(iter, 1, \"aaa - Just add Element - aaa\");", + "", + " el.append(out iter);", + "", + " ", + " el.set_value(iter, 0, \"\");", + " el.set_value(iter, 1, \"-- select a module --\");", + " _this.build_module.el.set_active_iter(iter);", + " ", + " for (var i = 0; i < data.size;i++) {", + " ", + "", + " el.append(out iter);", + " ", + " el.set_value(iter, 0, data.get(i));", + " el.set_value(iter, 1, data.get(i));", + " ", + " if (data.get(i) == cur) {", + " _this.build_module.el.set_active_iter(iter);", + " }", + " ", + " }", + " this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING); ", + " ", + "}", + "" + ] } - ] + ], + "xtype" : "ComboBox" }, { - "label" : "Directory", + "$ justify" : "Gtk.Justification.RIGHT", "$ visible" : true, - "xalign" : 0.90000000000000002, + "$ xns" : "Gtk", "* pack" : "attach,0,8,1,1", - "xtype" : "Label", - "$ justify" : "Gtk.Justification.RIGHT", + "label" : "Directory", "x_options" : 4, - "$ xns" : "Gtk" + "xalign" : 0.90000000000000002, + "xtype" : "Label" }, { - "id" : "dir", + "$ xns" : "Gtk", "* init" : "this.el.add_attribute(_this.dircellrenderer.el , \"markup\", 1 );", "* pack" : "attach,1,8,1,1", - "xtype" : "ComboBox", - "$ xns" : "Gtk", + "id" : "dir", "items" : [ { - "id" : "dircellrenderer", - "xtype" : "CellRendererText", + "$ xns" : "Gtk", "* pack" : "pack_start,true", - "$ xns" : "Gtk" + "id" : "dircellrenderer", + "xtype" : "CellRendererText" }, { - "id" : "dirmodel", - "xtype" : "ListStore", - "* pack" : "set_model", "$ columns" : "typeof(string),typeof(string)", - "n_columns" : 2, "$ xns" : "Gtk", - "| void loadData" : " () {\n\t\n\t\n \n this.el.clear(); \n \n if (!(_this.project is Project.Gtk)) {\n\t\treturn;\n\t}\n var sd = ((Project.Gtk)_this.project).sourcedirs();\n \n Gtk.TreeIter iter;\n var el = this.el;\n \n /// el.append(out iter);\n \n \n // el.set_value(iter, 0, \"\");\n // el.set_value(iter, 1, \"aaa - Just add Element - aaa\");\n\n// el.append(out iter);\n\n \n// el.set_value(iter, 0, \"\");\n // el.set_value(iter, 1, \"-- select a directoyr --\");\n //_this.build_module.el.set_active_iter(iter);\n \n for (var i = 0; i < sd.length;i++) {\n \n\n el.append(out iter);\n \n el.set_value(iter, 0, sd[i]);\n el.set_value(iter, 1, sd[i]);\n \n //if (data.get(i) == cur) {\n // _this.build_module.el.set_active_iter(iter);\n // }\n \n }\n // this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING); \n \n}\n" + "* pack" : "set_model", + "id" : "dirmodel", + "n_columns" : 2, + "xtype" : "ListStore", + "| void loadData" : [ + " () {", + "\t", + "\t", + " ", + " this.el.clear(); ", + " ", + " if (!(_this.project is Project.Gtk)) {", + "\t\treturn;", + "\t}", + " var sd = ((Project.Gtk)_this.project).sourcedirs();", + " ", + " Gtk.TreeIter iter;", + " var el = this.el;", + " ", + " /// el.append(out iter);", + " ", + " ", + " // el.set_value(iter, 0, \"\");", + " // el.set_value(iter, 1, \"aaa - Just add Element - aaa\");", + "", + "// el.append(out iter);", + "", + " ", + "// el.set_value(iter, 0, \"\");", + " // el.set_value(iter, 1, \"-- select a directoyr --\");", + " //_this.build_module.el.set_active_iter(iter);", + " ", + " for (var i = 0; i < sd.length;i++) {", + " ", + "", + " el.append(out iter);", + " ", + " el.set_value(iter, 0, sd[i]);", + " el.set_value(iter, 1, sd[i]);", + " ", + " //if (data.get(i) == cur) {", + " // _this.build_module.el.set_active_iter(iter);", + " // }", + " ", + " }", + " // this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING); ", + " ", + "}", + "" + ] } - ] + ], + "xtype" : "ComboBox" } - ] + ], + "n_columns" : 2, + "n_rows" : 7, + "uint row_spacing" : 2, + "xtype" : "Grid" }, { - "int margin_bottom" : 4, - "int margin_right" : 4, - "* pack" : "pack_end,false,true,0", - "xtype" : "HButtonBox", "$ xns" : "Gtk", + "* pack" : "pack_end,false,true,0", + "int margin_bottom" : 4, "int margin_left" : 4, + "int margin_right" : 4, "items" : [ { + "$ xns" : "Gtk", + "* pack" : "add", "listeners" : { - "clicked" : "() => { \n\n _this.done = true;\n _this.el.hide(); \n}" + "clicked" : [ + "() => { ", + "", + " _this.done = true;", + " _this.el.hide(); ", + "}" + ] }, "string label" : "Cancel", - "* pack" : "add", - "xtype" : "Button", - "$ xns" : "Gtk" + "xtype" : "Button" }, { + "$ xns" : "Gtk", + "* pack" : "add", + "id" : "save_btn", "listeners" : { - "clicked" : "( ) => { \n\n \n\n\n\tif (_this.name.el.get_text().length < 1) {\n\t StandardErrorDialog.show(\n\t _this.mainwindow.el,\n\t \"You have to set Component name \"\n\t );\n\t \n\t return;\n\t}\n\t// what does this do?\n\t\n\tvar isNew = _this.file.name.length > 0 ? false : true;\n\t/*\n\tif (!isNew && this.file.name != _this.name.el.get_text()) {\n\t Xcls_StandardErrorDialog.singleton().show(\n\t this.el,\n\t \"Sorry changing names does not work yet. \"\n\t );\n\t \n\t return;\n\t}\n\t*/\n\t \n\t\n \n\t// FIXME - this may be more complicated...\n\t//for (var i in this.def) {\n\t// this.file[i] = this.get(i).el.get_text();\n\t//}\n\n\tif (!isNew) {\n\t try {\n\t _this.updateFileFromEntry();\n\t } catch( JsRender.Error.RENAME_FILE_EXISTS er) {\n\t Xcls_StandardErrorDialog.singleton().show(\n\t _this.mainwindow.el,\n\t \"The name you used already exists \"\n\t );\n\t return;\n\t \n\t }\n\n\t _this.done = true;\n\t _this.file.save();\n\t _this.el.hide();\n\t return;\n\t}\n\t\n\t// ---------------- NEW FILES...\n\tGtk.TreeIter iter;\n\n\tif (!_this.filetype.el.get_active_iter(out iter)) {\n\t\t// should not happen...\n\t\t// so we are jut going to return without \n\t\tStandardErrorDialog.show(\n\t _this.mainwindow.el,\n\t \"You must select a file type. \"\n\t );\n\t return;\n\t\t \n\t}\n\t\n\t\n\tvar fn = _this.name.el.get_text();\n\t\n\tValue ftypename;\n\t_this.ftdbmodel.el.get_value (iter, 0, out ftypename);\n\tvar ext = ((string)ftypename);\n\tvar dir = _this.project.firstPath(); \n\tif (ext != \"bjs\") {\n\t \n\t\tif (!_this.dir.el.get_active_iter(out iter)) {\n\t\t\t// should not happen...\n\t\t\t// so we are jut going to return without \n\t\t\tStandardErrorDialog.show(\n\t\t\t _this.mainwindow.el,\n\t\t\t \"You must select a directory \"\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tValue vdir;\n\t\t_this.dirmodel.el.get_value (iter, 0, out vdir);\n\t\tdir = (string)vdir;\n\t}\n\t\n\tvar targetfile = dir + \"/\" + fn;\n\t\n\t// strip the file type off the end..\n\t\n\t\n var rx = new GLib.Regex(\"\\\\.\" + ext + \"$\",GLib.RegexCompileFlags.CASELESS);\n targetfile = rx.replace(targetfile, targetfile.length, 0, \"\"); \n \n\tif (GLib.FileUtils.test(targetfile + \".\" + ext, GLib.FileTest.EXISTS)) {\n\t Xcls_StandardErrorDialog.singleton().show(\n\t _this.mainwindow.el,\n\t \"That file already exists\"\n\t ); \n\t return;\n\t}\n \n var f = JsRender.JsRender.factory(\n\t\text == \"bjs\" ? _this.file.project.xtype : \"PlainFile\", \n\t\t_this.file.project, \n\t\ttargetfile + \".\" + ext);\n\n\t_this.file = f;\n\t\n\n\t\n\t_this.updateFileFromEntry();\n\t_this.file.loaded = true;\n\t_this.file.save();\n\tif (ext == \"bjs\") {\n\t\t_this.file.project.addFile(_this.file);\n\t}\n\t\n \n\t// what about .js ?\n _this.done = true;\n\t_this.el.hide();\n\n// hopefull this will work with bjs files..\n\t\n\t_this.success(_this.project, _this.file);\n \n}" + "clicked" : [ + "( ) => { ", + "", + " ", + "", + "", + "\tif (_this.name.el.get_text().length < 1) {", + "\t StandardErrorDialog.show(", + "\t _this.mainwindow.el,", + "\t \"You have to set Component name \"", + "\t );", + "\t ", + "\t return;", + "\t}", + "\t// what does this do?", + "\t", + "\tvar isNew = _this.file.name.length > 0 ? false : true;", + "\t/*", + "\tif (!isNew && this.file.name != _this.name.el.get_text()) {", + "\t Xcls_StandardErrorDialog.singleton().show(", + "\t this.el,", + "\t \"Sorry changing names does not work yet. \"", + "\t );", + "\t ", + "\t return;", + "\t}", + "\t*/", + "\t ", + "\t", + " ", + "\t// FIXME - this may be more complicated...", + "\t//for (var i in this.def) {", + "\t// this.file[i] = this.get(i).el.get_text();", + "\t//}", + "", + "\tif (!isNew) {", + "\t try {", + "\t _this.updateFileFromEntry();", + "\t } catch( JsRender.Error.RENAME_FILE_EXISTS er) {", + "\t Xcls_StandardErrorDialog.singleton().show(", + "\t _this.mainwindow.el,", + "\t \"The name you used already exists \"", + "\t );", + "\t return;", + "\t ", + "\t }", + "", + "\t _this.done = true;", + "\t _this.file.save();", + "\t _this.el.hide();", + "\t return;", + "\t}", + "\t", + "\t// ---------------- NEW FILES...", + "\tGtk.TreeIter iter;", + "", + "\tif (!_this.filetype.el.get_active_iter(out iter)) {", + "\t\t// should not happen...", + "\t\t// so we are jut going to return without ", + "\t\tStandardErrorDialog.show(", + "\t _this.mainwindow.el,", + "\t \"You must select a file type. \"", + "\t );", + "\t return;", + "\t\t ", + "\t}", + "\t", + "\t", + "\tvar fn = _this.name.el.get_text();", + "\t", + "\tValue ftypename;", + "\t_this.ftdbmodel.el.get_value (iter, 0, out ftypename);", + "\tvar ext = ((string)ftypename);", + "\tvar dir = _this.project.firstPath(); ", + "\tif (ext != \"bjs\") {", + "\t ", + "\t\tif (!_this.dir.el.get_active_iter(out iter)) {", + "\t\t\t// should not happen...", + "\t\t\t// so we are jut going to return without ", + "\t\t\tStandardErrorDialog.show(", + "\t\t\t _this.mainwindow.el,", + "\t\t\t \"You must select a directory \"", + "\t\t\t);", + "\t\t\treturn;", + "\t\t}", + "\t\tValue vdir;", + "\t\t_this.dirmodel.el.get_value (iter, 0, out vdir);", + "\t\tdir = (string)vdir;", + "\t}", + "\t", + "\tvar targetfile = dir + \"/\" + fn;", + "\t", + "\t// strip the file type off the end..", + "\t", + "\t", + " var rx = new GLib.Regex(\"\\\\.\" + ext + \"$\",GLib.RegexCompileFlags.CASELESS);", + " targetfile = rx.replace(targetfile, targetfile.length, 0, \"\"); ", + " ", + "\tif (GLib.FileUtils.test(targetfile + \".\" + ext, GLib.FileTest.EXISTS)) {", + "\t Xcls_StandardErrorDialog.singleton().show(", + "\t _this.mainwindow.el,", + "\t \"That file already exists\"", + "\t ); ", + "\t return;", + "\t}", + " ", + " var f = JsRender.JsRender.factory(", + "\t\text == \"bjs\" ? _this.file.project.xtype : \"PlainFile\", ", + "\t\t_this.file.project, ", + "\t\ttargetfile + \".\" + ext);", + "", + "\t_this.file = f;", + "\t", + "", + "\t", + "\t_this.updateFileFromEntry();", + "\t_this.file.loaded = true;", + "\t_this.file.save();", + "\tif (ext == \"bjs\") {", + "\t\t_this.file.project.addFile(_this.file);", + "\t}", + "\t", + " ", + "\t// what about .js ?", + " _this.done = true;", + "\t_this.el.hide();", + "", + "// hopefull this will work with bjs files..", + "\t", + "\t_this.success(_this.project, _this.file);", + " ", + "}" + ] }, - "id" : "save_btn", - "* pack" : "add", - "xtype" : "Button", "string label" : "Save", - "$ xns" : "Gtk" + "xtype" : "Button" } - ] + ], + "xtype" : "HButtonBox" } - ] + ], + "xtype" : "Box" } + ], + "listeners" : { + "closed" : [ + "() => {", + " if (!this.done) {", + " _this.el.show();", + " ", + " }", + "} " + ] + }, + "uint border_width" : 0, + "xtype" : "Popover", + "| void updateFileFromEntry" : [ + "() {", + "", + " _this.file.title = _this.title.el.get_text();", + " _this.file.region = _this.region.el.get_text(); ", + " _this.file.parent = _this.parent.el.get_text(); ", + " _this.file.permname = _this.permname.el.get_text(); ", + " _this.file.modOrder = _this.modOrder.el.get_text();", + " ", + " if (_this.file.name.length > 0 && _this.file.name != _this.name.el.get_text()) {", + " _this.file.renameTo(_this.name.el.get_text());", + " }", + " // store the module...", + " _this.file.build_module = \"\"; ", + " Gtk.TreeIter iter; ", + " if (_this.build_module.el.get_active_iter (out iter)) {", + " Value vfname;", + " this.dbmodel.el.get_value (iter, 0, out vfname);", + " if (((string)vfname).length > 0) {", + " _this.file.build_module = (string)vfname;", + " }", + " ", + " }", + " ", + " ", + "", + " ", + "} " + ], + "| void show" : [ + "(JsRender.JsRender c, Gtk.Widget btn) ", + "{", + " this.project = c.project;", + " this.done = false;", + " ", + " ", + " //if (!this.el) {", + " //this.init();", + " //}", + " ", + " _this.name.el.set_text(c.name);", + " _this.title.el.set_text(c.title);", + " _this.parent.el.set_text(c.parent); ", + " _this.region.el.set_text(c.region);", + " _this.modOrder.el.set_text(c.modOrder);", + " _this.permname.el.set_text(c.permname);", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " var ar = new Gee.ArrayList();", + " _this.dbmodel.loadData(ar,\"\");", + " // load the modules... if relivant..", + " if (this.project.xtype == \"Gtk\") {", + " var p = (Project.Gtk)c.project;", + " var cg = p.compilegroups;", + "", + " var iter = cg.map_iterator();", + " while(iter.next()) {", + " var key = iter.get_key();", + " if (key == \"_default_\") {", + " continue;", + " }", + " ar.add(key);", + " };", + " _this.dbmodel.loadData(ar, c.build_module);", + "", + " }", + " ", + " ", + " _this.file = c;", + " //console.log('show all');", + " this.el.set_modal(true);", + " this.el.set_relative_to(btn);", + "", + " this.el.set_position(Gtk.PositionType.RIGHT);", + " ", + " // window + header?", + " print(\"SHOWALL - POPIP\\n\");", + " this.el.show_all();", + " this.name.el.grab_focus();", + " ", + " ", + " ", + " if (c.path.length > 0) {", + "\t this.save_btn.el.set_label(\"Save\");", + "\t\t_this.filetype.el.hide();", + "\t\t_this.filetypelbl.el.hide();", + "\t\t_this.filetype.showhide(true); // as we only work on bjs files currently", + " } else {", + " this.save_btn.el.set_label(\"Create\");", + " _this.ftdbmodel.loadData(\"bjs\"); // fixme - need to determine type..", + "\t _this.filetype.el.show();", + "\t _this.filetypelbl.el.show();", + " }", + " ", + " ", + " //this.success = c.success;", + " ", + " ", + "}" ] } - ] + ], + "modOrder" : "", + "name" : "PopoverFileDetails", + "parent" : "", + "path" : "/home/alan/gitlive/roobuilder/src/Builder4/PopoverFileDetails.bjs", + "permname" : "", + "title" : "" } \ No newline at end of file diff --git a/src/Builder4/PopoverProperty.bjs b/src/Builder4/PopoverProperty.bjs index 58090b9c4..006c39c74 100644 --- a/src/Builder4/PopoverProperty.bjs +++ b/src/Builder4/PopoverProperty.bjs @@ -1,129 +1,319 @@ { - "name" : "PopoverProperty", - "parent" : "", - "title" : "", - "path" : "/home/alan/gitlive/roobuilder/src/Builder4/PopoverProperty.bjs", - "permname" : "", - "modOrder" : "", "build_module" : "builder", "items" : [ { - "listeners" : { - "closed" : "() => {\n \n \n var newtext = \"\";\n Gtk.TreeIter citer;\n GLib.Value gval;\n this.kflag.el.get_active_iter(out citer);\n this.dbmodel.el.get_value(citer, 0, out gval);\n \n var ktype = this.ktype.el.get_text().strip(); \n var kname = this.kname.el.get_text().strip(); \n newtext += ((string)gval).strip(); \n newtext += ktype.length > 0 && newtext.length > 0 ? \" \" :\"\";\n newtext += ktype;\n newtext += kname.length > 0 && newtext.length > 0 ? \" \" :\"\";\n newtext += kname;\n \n \n var lp = _this.mainwindow.windowstate.left_props;\n \n switch(this.key_type) {\n case \"listener\":\n var ov = _this.node.listeners.get(this.old_keyname);\n _this.node.listeners.set(newtext, ov);\n if (this.old_keyname != newtext) { \n\t _this.node.listeners.unset(this.old_keyname);\n }\n \n \n lp.updateKey(this.old_keyname, this.key_type, newtext);\n \n break;\n case \"props\":\n var ov = _this.node.props.get(this.old_keyname);\n _this.node.props.set(newtext, ov);\n\t\t\tif (this.old_keyname != newtext) { \n\t _this.node.props.unset(this.old_keyname);\n }\n lp.updateKey(this.old_keyname, this.key_type, newtext);\n break;\n }\n \n \n \n} " - }, - "string old_keyname" : "", - "id" : "PopoverProperty", + "$ xns" : "Gtk", "@ void success" : "(Project.Project pr, JsRender.JsRender file)", - "| void show" : "(Gtk.Widget btn, JsRender.Node node, string key_type, string key) \n\t{\n\t\n\tstring kname = \"\", kflag = \"\", ktype = \"\";\n\tif (key.length > 0) {\n\t\tnode.normalize_key( key, out kname, out kflag, out ktype);\n\t}\n\n\tif (key_type == \"listener\") {\n\t\tthis.header.el.title = \"Modify Event Listener\";\n\t} else {\n\t\tthis.header.el.title = \"Modify Property\";\n\t}\n\t\n\tthis.key_type = key_type;\n\tthis.old_keyname = key;\n\tthis.node = node;\n\t\n\t_this.kname.el.set_text(kname);\n\t_this.ktype.el.set_text(ktype);\n\t\n\t_this.dbmodel.loadData(kflag);\n\t// does node have this property...\n\n\n\t \n\n\t_this.node = node;\n\t//console.log('show all');\n\tthis.el.set_modal(true);\n\tthis.el.set_relative_to(btn);\n\n\tthis.el.set_position(Gtk.PositionType.TOP);\n\n\t// window + header?\n\t print(\"SHOWALL - POPIP\\n\");\n\tthis.el.show_all();\n\tthis.kname.el.grab_focus();\n\n\t//this.success = c.success;\n \n}", - "bool done" : false, - "| void updateNodeFromValues" : "() {\n\n /* _this.file.title = _this.title.el.get_text();\n _this.file.region = _this.region.el.get_text(); \n _this.file.parent = _this.parent.el.get_text(); \n _this.file.permname = _this.permname.el.get_text(); \n _this.file.modOrder = _this.modOrder.el.get_text();\n \n if (_this.file.name.length > 0 && _this.file.name != _this.name.el.get_text()) {\n _this.file.renameTo(_this.name.el.get_text());\n }\n // store the module...\n _this.file.build_module = \"\"; \n Gtk.TreeIter iter; \n if (_this.build_module.el.get_active_iter (out iter)) {\n Value vfname;\n this.dbmodel.el.get_value (iter, 0, out vfname);\n if (((string)vfname).length > 0) {\n _this.file.build_module = (string)vfname;\n }\n \n }\n */\n \n \n\n \n} ", - "xtype" : "Popover", "Gtk.PositionType position" : "Gtk.PositionType.RIGHT", - "$ xns" : "Gtk", + "JsRender.Node node" : "", "Xcls_MainWindow mainwindow" : "null", + "bool done" : false, "bool modal" : true, - "string key_type" : "", - "uint border_width" : 0, - "JsRender.Node node" : "", + "id" : "PopoverProperty", "items" : [ { - "bool homogeneous" : false, - "xtype" : "Box", "$ pack" : "add", "$ xns" : "Gtk", "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", + "bool homogeneous" : false, "items" : [ { - "id" : "header", - "xtype" : "HeaderBar", - "* pack" : "pack_start,false,true,0", "$ xns" : "Gtk", - "string title" : "Modify / Create Property" + "* pack" : "pack_start,false,true,0", + "id" : "header", + "string title" : "Modify / Create Property", + "xtype" : "HeaderBar" }, { - "int margin_right" : 4, - "xtype" : "Table", - "* pack" : "pack_start,false,false,4", - "uint row_spacing" : 2, - "n_columns" : 2, - "$ xns" : "Gtk", - "n_rows" : 3, "$ homogeneous" : true, + "$ xns" : "Gtk", + "* pack" : "pack_start,false,false,4", "int margin_left" : 4, + "int margin_right" : 4, "items" : [ { - "label" : "Special Flags", - "xalign" : 0.90000000000000002, - "* pack" : "attach_defaults,0,1,0,1", - "xtype" : "Label", "$ justify" : "Gtk.Justification.RIGHT", + "$ xns" : "Gtk", + "* pack" : "attach_defaults,0,1,0,1", + "label" : "Special Flags", "x_options" : 4, - "$ xns" : "Gtk" + "xalign" : 0.90000000000000002, + "xtype" : "Label" }, { - "id" : "kflag", + "$ xns" : "Gtk", "* init" : "this.el.add_attribute(_this.dbcellrenderer.el , \"markup\", 1 );", "* pack" : "attach_defaults,1,2,0,1", - "xtype" : "ComboBox", - "$ xns" : "Gtk", + "id" : "kflag", "items" : [ { - "id" : "dbcellrenderer", + "$ xns" : "Gtk", "* pack" : "pack_start,true", - "xtype" : "CellRendererText", - "$ xns" : "Gtk" + "id" : "dbcellrenderer", + "xtype" : "CellRendererText" }, { - "id" : "dbmodel", - "* pack" : "set_model", - "xtype" : "ListStore", "$ columns" : "typeof(string),typeof(string)", - "n_columns" : 2, "$ xns" : "Gtk", - "| void loadData" : " (string kflag) {\n this.el.clear(); \n Gtk.TreeIter iter;\n var el = this.el;\n \n \n // vala signal.. '@'\n // raw value '$'\n // user defined property '#'\n // user defined method '|'\n // special property '*' => prop |args|ctor|init\n \n \n \n /// el.append(out iter);\n \n \n // el.set_value(iter, 0, \"\");\n // el.set_value(iter, 1, \"aaa - Just add Element - aaa\");\n\n el.append(out iter);\n el.set(iter, 0, \"\", 1, \"Normal Property\", -1);\n\t \n\tif (_this.mainwindow.windowstate.file.xtype == \"Gtk\") {\n\t\tel.append(out iter);\n\t\tel.set(iter, 0, \"$\", 1, \"($) Raw Property (not escaped)\", -1);\n\t\t \n\t\t\n\t\tel.append(out iter);\n\t\tel.set(iter, 0, \"#\", 1, \"(#) User defined property\", -1);\n\t\t \n\t\tel.append(out iter);\n\t\tel.set(iter, 0, \"|\", 1, \"(|) User defined method\", -1);\n\t\t \n\t\tel.append(out iter);\n\t\tel.set(iter, 0, \"*\", 1, \"(*) Special property (eg. prop | args | ctor | init )\", -1);\n\t\t \n\t\t\n\t\tel.append(out iter);\n\t el.set(iter, 0, \"@\", 1, \"(@) Vala Signal\", -1);\n\t\t \n\t\t\n\t} else { \n\t\t// javascript\n\t\tel.append(out iter);\n\t\tel.set(iter, 0, \"$\", 1, \"($) Raw Property (not escaped)\", -1);\n\t\t \n\t\tel.append(out iter);\n\t\tel.set(iter, 0, \"|\", 1, \"(|) User defined method\", -1);\n\t \n\t\tel.append(out iter);\n\t\tel.set(iter, 0, \"*\", 1, \"(*) Special property (eg. prop )\", -1);\n\t\t \n\t\n\t}\n\tel.foreach((tm, tp, titer) => {\n\t\tGLib.Value val;\n\t\tel.get_value(titer, 0, out val);\n\t\t \n\t\tprint(\"check %s against %s\\n\", (string)val, kflag);\n\t\tif (((string)val) == kflag) {\n\t\t\t_this.kflag.el.set_active_iter(titer);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t});\n\t\n\n \n}\n" + "* pack" : "set_model", + "id" : "dbmodel", + "n_columns" : 2, + "xtype" : "ListStore", + "| void loadData" : [ + " (string kflag) {", + " this.el.clear(); ", + " Gtk.TreeIter iter;", + " var el = this.el;", + " ", + " ", + " // vala signal.. '@'", + " // raw value '$'", + " // user defined property '#'", + " // user defined method '|'", + " // special property '*' => prop |args|ctor|init", + " ", + " ", + " ", + " /// el.append(out iter);", + " ", + " ", + " // el.set_value(iter, 0, \"\");", + " // el.set_value(iter, 1, \"aaa - Just add Element - aaa\");", + "", + " el.append(out iter);", + " el.set(iter, 0, \"\", 1, \"Normal Property\", -1);", + "\t ", + "\tif (_this.mainwindow.windowstate.file.xtype == \"Gtk\") {", + "\t\tel.append(out iter);", + "\t\tel.set(iter, 0, \"$\", 1, \"($) Raw Property (not escaped)\", -1);", + "\t\t ", + "\t\t", + "\t\tel.append(out iter);", + "\t\tel.set(iter, 0, \"#\", 1, \"(#) User defined property\", -1);", + "\t\t ", + "\t\tel.append(out iter);", + "\t\tel.set(iter, 0, \"|\", 1, \"(|) User defined method\", -1);", + "\t\t ", + "\t\tel.append(out iter);", + "\t\tel.set(iter, 0, \"*\", 1, \"(*) Special property (eg. prop | args | ctor | init )\", -1);", + "\t\t ", + "\t\t", + "\t\tel.append(out iter);", + "\t el.set(iter, 0, \"@\", 1, \"(@) Vala Signal\", -1);", + "\t\t ", + "\t\t", + "\t} else { ", + "\t\t// javascript", + "\t\tel.append(out iter);", + "\t\tel.set(iter, 0, \"$\", 1, \"($) Raw Property (not escaped)\", -1);", + "\t\t ", + "\t\tel.append(out iter);", + "\t\tel.set(iter, 0, \"|\", 1, \"(|) User defined method\", -1);", + "\t ", + "\t\tel.append(out iter);", + "\t\tel.set(iter, 0, \"*\", 1, \"(*) Special property (eg. prop )\", -1);", + "\t\t ", + "\t", + "\t}", + "\tel.foreach((tm, tp, titer) => {", + "\t\tGLib.Value val;", + "\t\tel.get_value(titer, 0, out val);", + "\t\t ", + "\t\tprint(\"check %s against %s\\n\", (string)val, kflag);", + "\t\tif (((string)val) == kflag) {", + "\t\t\t_this.kflag.el.set_active_iter(titer);", + "\t\t\treturn true;", + "\t\t}", + "\t\treturn false;", + "\t});", + "\t", + "", + " ", + "}", + "" + ] } - ] + ], + "xtype" : "ComboBox" }, { - "label" : "Type or Return Type", + "$ justify" : "Gtk.Justification.RIGHT", "$ visible" : true, - "xalign" : 0.90000000000000002, + "$ xns" : "Gtk", "* pack" : "attach_defaults,0,1,1,2", - "xtype" : "Label", - "$ justify" : "Gtk.Justification.RIGHT", + "label" : "Type or Return Type", "x_options" : 4, - "$ xns" : "Gtk" + "xalign" : 0.90000000000000002, + "xtype" : "Label" }, { - "id" : "ktype", "$ visible" : true, - "xtype" : "Entry", + "$ xns" : "Gtk", "* pack" : "attach_defaults,1,2,1,2", - "$ xns" : "Gtk" + "id" : "ktype", + "xtype" : "Entry" }, { - "label" : "Name", + "$ justify" : "Gtk.Justification.RIGHT", "$ visible" : true, - "tooltip_text" : "center, north, south, east, west", - "xalign" : 0.90000000000000002, + "$ xns" : "Gtk", "* pack" : "attach_defaults,0,1,2,3", - "xtype" : "Label", - "$ justify" : "Gtk.Justification.RIGHT", + "label" : "Name", + "tooltip_text" : "center, north, south, east, west", "x_options" : 4, - "$ xns" : "Gtk" + "xalign" : 0.90000000000000002, + "xtype" : "Label" }, { - "id" : "kname", "$ visible" : true, - "xtype" : "Entry", + "$ xns" : "Gtk", "* pack" : "attach_defaults,1,2,2,3", - "$ xns" : "Gtk" + "id" : "kname", + "xtype" : "Entry" } - ] + ], + "n_columns" : 2, + "n_rows" : 3, + "uint row_spacing" : 2, + "xtype" : "Table" } - ] + ], + "xtype" : "Box" } + ], + "listeners" : { + "closed" : [ + "() => {", + " ", + " ", + " var newtext = \"\";", + " Gtk.TreeIter citer;", + " GLib.Value gval;", + " this.kflag.el.get_active_iter(out citer);", + " this.dbmodel.el.get_value(citer, 0, out gval);", + " ", + " var ktype = this.ktype.el.get_text().strip(); ", + " var kname = this.kname.el.get_text().strip(); ", + " newtext += ((string)gval).strip(); ", + " newtext += ktype.length > 0 && newtext.length > 0 ? \" \" :\"\";", + " newtext += ktype;", + " newtext += kname.length > 0 && newtext.length > 0 ? \" \" :\"\";", + " newtext += kname;", + " ", + " ", + " var lp = _this.mainwindow.windowstate.left_props;", + " ", + " switch(this.key_type) {", + " case \"listener\":", + " var ov = _this.node.listeners.get(this.old_keyname);", + " _this.node.listeners.set(newtext, ov);", + " if (this.old_keyname != newtext) { ", + "\t _this.node.listeners.unset(this.old_keyname);", + " }", + " ", + " ", + " lp.updateKey(this.old_keyname, this.key_type, newtext);", + " ", + " break;", + " case \"props\":", + " var ov = _this.node.props.get(this.old_keyname);", + " _this.node.props.set(newtext, ov);", + "\t\t\tif (this.old_keyname != newtext) { ", + "\t _this.node.props.unset(this.old_keyname);", + " }", + " lp.updateKey(this.old_keyname, this.key_type, newtext);", + " break;", + " }", + " ", + " ", + " ", + "} " + ] + }, + "string key_type" : "", + "string old_keyname" : "", + "uint border_width" : 0, + "xtype" : "Popover", + "| void updateNodeFromValues" : [ + "() {", + "", + " /* _this.file.title = _this.title.el.get_text();", + " _this.file.region = _this.region.el.get_text(); ", + " _this.file.parent = _this.parent.el.get_text(); ", + " _this.file.permname = _this.permname.el.get_text(); ", + " _this.file.modOrder = _this.modOrder.el.get_text();", + " ", + " if (_this.file.name.length > 0 && _this.file.name != _this.name.el.get_text()) {", + " _this.file.renameTo(_this.name.el.get_text());", + " }", + " // store the module...", + " _this.file.build_module = \"\"; ", + " Gtk.TreeIter iter; ", + " if (_this.build_module.el.get_active_iter (out iter)) {", + " Value vfname;", + " this.dbmodel.el.get_value (iter, 0, out vfname);", + " if (((string)vfname).length > 0) {", + " _this.file.build_module = (string)vfname;", + " }", + " ", + " }", + " */", + " ", + " ", + "", + " ", + "} " + ], + "| void show" : [ + "(Gtk.Widget btn, JsRender.Node node, string key_type, string key) ", + "\t{", + "\t", + "\tstring kname = \"\", kflag = \"\", ktype = \"\";", + "\tif (key.length > 0) {", + "\t\tnode.normalize_key( key, out kname, out kflag, out ktype);", + "\t}", + "", + "\tif (key_type == \"listener\") {", + "\t\tthis.header.el.title = \"Modify Event Listener\";", + "\t} else {", + "\t\tthis.header.el.title = \"Modify Property\";", + "\t}", + "\t", + "\tthis.key_type = key_type;", + "\tthis.old_keyname = key;", + "\tthis.node = node;", + "\t", + "\t_this.kname.el.set_text(kname);", + "\t_this.ktype.el.set_text(ktype);", + "\t", + "\t_this.dbmodel.loadData(kflag);", + "\t// does node have this property...", + "", + "", + "\t ", + "", + "\t_this.node = node;", + "\t//console.log('show all');", + "\tthis.el.set_modal(true);", + "\tthis.el.set_relative_to(btn);", + "", + "\tthis.el.set_position(Gtk.PositionType.TOP);", + "", + "\t// window + header?", + "\t print(\"SHOWALL - POPIP\\n\");", + "\tthis.el.show_all();", + "\tthis.kname.el.grab_focus();", + "", + "\t//this.success = c.success;", + " ", + "}" ] } - ] + ], + "modOrder" : "", + "name" : "PopoverProperty", + "parent" : "", + "path" : "/home/alan/gitlive/roobuilder/src/Builder4/PopoverProperty.bjs", + "permname" : "", + "title" : "" } \ No newline at end of file diff --git a/src/Builder4/WindowAddProp.bjs b/src/Builder4/WindowAddProp.bjs index 953599d9b..85041c797 100644 --- a/src/Builder4/WindowAddProp.bjs +++ b/src/Builder4/WindowAddProp.bjs @@ -1,62 +1,167 @@ { - "name" : "WindowAddProp", - "parent" : "", - "title" : "", - "path" : "/home/alan/gitlive/roobuilder/src/Builder4/WindowAddProp.bjs", - "permname" : "", - "modOrder" : "", "build_module" : "builder", "items" : [ { - "id" : "WindowAddProp", - "* init" : " this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n ", "$ shadow_type" : "Gtk.ShadowType.IN", - "| void show" : "(Palete.Palete pal, string etype, string xtype) {\n this.model.el.clear();\n\n Gtk.TreeIter iter;\n var elementList = pal.getPropertiesFor( xtype,etype);\n \n \n //print (\"GOT \" + elementList.length + \" items for \" + fullpath + \"|\" + type);\n // console.dump(elementList);\n \n var miter = elementList.map_iterator();\n while (miter.next()) {\n var p = miter.get_value();\n \n this.model.el.append(out iter);\n\n\t\tvar dname = p.name;\n\t\tvar dtype = p.type;\n\t\t \n\n this.model.el.set(iter,\n 0, p.name, \n 1, p.type,\n 2, \"\" + p.name +\" \"+p.type+\"\\n\" + \n GLib.Markup.escape_text(p.doctxt),\n 3, p.sig,\n 4, \"\" + dname +\" \"+dtype+\"\",\n 5, etype,\n -1\n );\n }\n this.model.el.set_sort_column_id(0,Gtk.SortType.ASCENDING);\n \n}\n", - "xtype" : "ScrolledWindow", - "@ void select" : "(string key, string type, string skel, string etype)", "$ xns" : "Gtk", - "| void clear" : "() {\n this.model.el.clear();\n\n}", + "* init" : [ + " this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);", + " " + ], + "@ void select" : "(string key, string type, string skel, string etype)", + "id" : "WindowAddProp", "items" : [ { - "listeners" : { - "row_activated" : "(path, column) => {\n\n Gtk.TreeIter iter;\n\n\n var m = _this.model;\n \n m.el.get_iter(out iter,path);\n \n \n // var val = \"\";\n \n \n var key = m.getValue(iter, 0);\n \n var type = m.getValue(iter, 1);\n var skel = m.getValue(iter, 3);\n var etype = m.getValue(iter, 5);\n \n \n _this.select(key,etype == \"signals\" ? \"\" : type,skel, etype);\n \n}\n " - }, - "* init" : "{ \n var description = new Pango.FontDescription();\n description.set_size(8000);\n this.el.override_font(description); \n \n this.el.get_selection().set_mode( Gtk.SelectionMode.SINGLE);\n \n\n \n \n \n}\n", - "tooltip_column" : 2, - "xtype" : "TreeView", - "* pack" : "add", "$ enable_tree_lines" : true, "$ headers_visible" : true, "$ xns" : "Gtk", + "* init" : [ + "{ ", + " var description = new Pango.FontDescription();", + " description.set_size(8000);", + " this.el.override_font(description); ", + " ", + " this.el.get_selection().set_mode( Gtk.SelectionMode.SINGLE);", + " ", + "", + " ", + " ", + " ", + "}", + "" + ], + "* pack" : "add", "items" : [ { - "| string getValue" : "(Gtk.TreeIter iter, int col)\n{\n\n GLib.Value value;\n this.el.get_value(iter, col, out value);\n\n return (string)value;\n \n}", - "id" : "model", + "$ columns" : [ + "typeof(string), // 0 real key", + "typeof(string), // 1 real type", + "typeof(string), // 2 docs ?", + "typeof(string), // 3 visable desc", + "typeof(string), // 4 function desc", + "typeof(string) // 5 element type (event|prop)", + " " + ], + "$ xns" : "Gtk", "* pack" : "set_model", - "xtype" : "ListStore", - "$ columns" : "typeof(string), // 0 real key\ntypeof(string), // 1 real type\ntypeof(string), // 2 docs ?\ntypeof(string), // 3 visable desc\ntypeof(string), // 4 function desc\ntypeof(string) // 5 element type (event|prop)\n ", + "id" : "model", "n_columns" : 6, - "$ xns" : "Gtk" + "xtype" : "ListStore", + "| string getValue" : [ + "(Gtk.TreeIter iter, int col)", + "{", + "", + " GLib.Value value;", + " this.el.get_value(iter, col, out value);", + "", + " return (string)value;", + " ", + "}" + ] }, { - "id" : "namecol", - "utf8 title" : "Double click to add", - "* init" : " this.el.add_attribute(_this.namerender.el , \"markup\", 4 );\n \n", - "xtype" : "TreeViewColumn", - "* pack" : "append_column", "$ xns" : "Gtk", + "* init" : [ + " this.el.add_attribute(_this.namerender.el , \"markup\", 4 );", + " ", + "" + ], + "* pack" : "append_column", + "id" : "namecol", "items" : [ { - "id" : "namerender", - "xtype" : "CellRendererText", + "$ xns" : "Gtk", "* pack" : "pack_start,true", - "$ xns" : "Gtk" + "id" : "namerender", + "xtype" : "CellRendererText" } - ] + ], + "utf8 title" : "Double click to add", + "xtype" : "TreeViewColumn" } - ] + ], + "listeners" : { + "row_activated" : [ + "(path, column) => {", + "", + " Gtk.TreeIter iter;", + "", + "", + " var m = _this.model;", + " ", + " m.el.get_iter(out iter,path);", + " ", + " ", + " // var val = \"\";", + " ", + " ", + " var key = m.getValue(iter, 0);", + " ", + " var type = m.getValue(iter, 1);", + " var skel = m.getValue(iter, 3);", + " var etype = m.getValue(iter, 5);", + " ", + " ", + " _this.select(key,etype == \"signals\" ? \"\" : type,skel, etype);", + " ", + "}", + " " + ] + }, + "tooltip_column" : 2, + "xtype" : "TreeView" } + ], + "xtype" : "ScrolledWindow", + "| void clear" : [ + "() {", + " this.model.el.clear();", + "", + "}" + ], + "| void show" : [ + "(Palete.Palete pal, string etype, string xtype) {", + " this.model.el.clear();", + "", + " Gtk.TreeIter iter;", + " var elementList = pal.getPropertiesFor( xtype,etype);", + " ", + " ", + " //print (\"GOT \" + elementList.length + \" items for \" + fullpath + \"|\" + type);", + " // console.dump(elementList);", + " ", + " var miter = elementList.map_iterator();", + " while (miter.next()) {", + " var p = miter.get_value();", + " ", + " this.model.el.append(out iter);", + "", + "\t\tvar dname = p.name;", + "\t\tvar dtype = p.type;", + "\t\t ", + "", + " this.model.el.set(iter,", + " 0, p.name, ", + " 1, p.type,", + " 2, \"\" + p.name +\" \"+p.type+\"\\n\" + ", + " GLib.Markup.escape_text(p.doctxt),", + " 3, p.sig,", + " 4, \"\" + dname +\" \"+dtype+\"\",", + " 5, etype,", + " -1", + " );", + " }", + " this.model.el.set_sort_column_id(0,Gtk.SortType.ASCENDING);", + " ", + "}", + "" ] } - ] + ], + "modOrder" : "", + "name" : "WindowAddProp", + "parent" : "", + "path" : "/home/alan/gitlive/roobuilder/src/Builder4/WindowAddProp.bjs", + "permname" : "", + "title" : "" } \ No newline at end of file diff --git a/src/Builder4/WindowRightPalete.bjs b/src/Builder4/WindowRightPalete.bjs index f342db506..a67782034 100644 --- a/src/Builder4/WindowRightPalete.bjs +++ b/src/Builder4/WindowRightPalete.bjs @@ -1,84 +1,225 @@ { - "name" : "WindowRightPalete", - "parent" : "", - "title" : "", - "path" : "/home/alan/gitlive/roobuilder/src/Builder4/WindowRightPalete.bjs", - "permname" : "", - "modOrder" : "", "build_module" : "builder", "items" : [ { - "id" : "RightPalete", - "@ void after_node_change(JsRender.Node? node)" : "", + "$ xns" : "Gtk", "* pack" : "add", - "xtype" : "Box", + "@ void after_node_change(JsRender.Node? node)" : "", "@ void before_node_change(JsRender.Node? node)" : "", - "| void load" : " (Palete.Palete pal, string cls ) {\n \n // this.get('model').expanded();\n \n var tr = pal.getChildList(cls);\n this.model.el.clear();\n\n\n Gtk.TreeIter citer;\n\n for(var i =0 ; i < tr.length; i++) {\n this.model.el.append(out citer); \n var dname = tr[i];\n if (dname.contains(\":\")) {\n\t\t\tvar ar = dname.split(\":\");\n\t\t\tdname = \"\" + ar[1] +\" - \"+ar[0]+\"\";\n\t\t}\n \n this.model.el.set_value(citer, 0, tr[i] ); // used data. \n this.model.el.set_value(citer, 1, dname ); // displayed value.\n \n }\n this.model.el.set_sort_column_id(1,Gtk.SortType.ASCENDING);\n \n} \n\n", "@ void drag_end()" : "", - "$ xns" : "Gtk", - "| void clear" : "() {\n this.model.el.clear();\n} ", "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", + "id" : "RightPalete", "items" : [ { - "id" : "viewbox", - "xtype" : "Box", - "* pack" : "pack_start,true,true,0", "$ xns" : "Gtk", + "* pack" : "pack_start,true,true,0", "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", + "id" : "viewbox", "items" : [ { - "* init" : " this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n this.el.set_size_request(-1,200);\n \n", "$ shadow_type" : "Gtk.ShadowType.IN", - "* pack" : "pack_start,true,true,0", - "xtype" : "ScrolledWindow", "$ xns" : "Gtk", + "* init" : [ + " this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);", + " this.el.set_size_request(-1,200);", + " ", + "" + ], + "* pack" : "pack_start,true,true,0", "items" : [ { - "listeners" : { - "button_press_event" : " ( event) => {\n\n //\tif (!this.get('/Editor').save()) {\n //\t // popup!! - click handled.. \n// \t return true;\n// }\n return false;\n}", - "drag_begin" : " ( ctx) => {\n // we could fill this in now...\n// Seed.print('SOURCE: drag-begin');\n \n \n \n Gtk.TreeIter iter;\n var s = this.el.get_selection();\n \n Gtk.TreeModel mod;\n s.get_selected(out mod, out iter);\n var path = mod.get_path(iter);\n \n /// pix is a surface..\n var pix = this.el.create_row_drag_icon ( path);\n \n \n Gtk.drag_set_icon_surface (ctx, pix);\n GLib.Value value;\n \n\n _this.model.el.get_value(iter, 0, out value);\n \n this.dragData = (string) value;\n \n \n return;\n}", - "drag_end" : "( drag_context) => {\n \t GLib.debug(\"SOURCE: drag-end (call listener on this)\\n\");\n\t\n\tthis.dragData = \"\";\n\t//this.dropList = null;\n\t_this.drag_end(); // call signal..\n\t//this.get('/LeftTree.view').highlight(false);\n\t \n}", - "drag_data_get" : "(drag_context, selection_data, info, time) => {\n \t//Seed.print('Palete: drag-data-get: ' + target_type);\n if (this.dragData.length < 1 ) {\n return; \n }\n \n GLib.debug(\"setting drag data to %s\\n\", this.dragData);\n // selection_data.set_text(this.dragData ,this.dragData.length);\n selection_data.set (selection_data.get_target (), 8, (uchar[]) this.dragData.to_utf8 ());\n\n //this.el.dragData = \"TEST from source widget\";\n \n \n}" - }, "# string dragData" : "", - "* init" : " {\n this.el.set_size_request(150,-1);\n // set_reorderable: [1]\n \n var description = new Pango.FontDescription();\n description.set_size(8000);\n this.el.override_font(description);\n \n var selection = this.el.get_selection();\n selection.set_mode( Gtk.SelectionMode.SINGLE);\n // this.selection.signal['changed'].connect(function() {\n // _view.listeners['cursor-changed'].apply(_view, [ _view, '']);\n //});\n // see: http://live.gnome.org/GnomeLove/DragNDropTutorial\n \n Gtk.drag_source_set (\n this.el, /* widget will be drag-able */\n Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */\n BuilderApplication.targetList, /* lists of target to support */\n Gdk.DragAction.COPY /* what to do with data after dropped */\n );\n //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList);\n \n // Gtk.drag_source_set_target_list(this.el, Application.targetList);\n // Gtk.drag_source_add_text_targets(this.el); \n \n}\n", - "xtype" : "TreeView", - "* pack" : "add", "$ enable_tree_lines" : true, "$ headers_visible" : true, "$ xns" : "Gtk", + "* init" : [ + " {", + " this.el.set_size_request(150,-1);", + " // set_reorderable: [1]", + " ", + " var description = new Pango.FontDescription();", + " description.set_size(8000);", + " this.el.override_font(description);", + " ", + " var selection = this.el.get_selection();", + " selection.set_mode( Gtk.SelectionMode.SINGLE);", + " // this.selection.signal['changed'].connect(function() {", + " // _view.listeners['cursor-changed'].apply(_view, [ _view, '']);", + " //});", + " // see: http://live.gnome.org/GnomeLove/DragNDropTutorial", + " ", + " Gtk.drag_source_set (", + " this.el, /* widget will be drag-able */", + " Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */", + " BuilderApplication.targetList, /* lists of target to support */", + " Gdk.DragAction.COPY /* what to do with data after dropped */", + " );", + " //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList);", + " ", + " // Gtk.drag_source_set_target_list(this.el, Application.targetList);", + " // Gtk.drag_source_add_text_targets(this.el); ", + " ", + "}", + "" + ], + "* pack" : "add", "items" : [ { - "| string getValue" : " (Gtk.TreeIter iter, int col) {\n GLib.Value gval;\n this.el.get_value(iter, col , out gval);\n return (string)gval;\n \n \n}", - "id" : "model", - "* pack" : "set_model", - "xtype" : "ListStore", "$ columns" : "typeof(string),typeof(string)", + "$ xns" : "Gtk", + "* pack" : "set_model", + "id" : "model", "n_columns" : 2, - "$ xns" : "Gtk" + "xtype" : "ListStore", + "| string getValue" : [ + " (Gtk.TreeIter iter, int col) {", + " GLib.Value gval;", + " this.el.get_value(iter, col , out gval);", + " return (string)gval;", + " ", + " ", + "}" + ] }, { - "utf8 title" : "Drag to add Object", - "* init" : " this.el.add_attribute(_this.txtrender.el , \"markup\", 1 );\n \n", - "* pack" : "append_column", - "xtype" : "TreeViewColumn", "$ xns" : "Gtk", + "* init" : [ + " this.el.add_attribute(_this.txtrender.el , \"markup\", 1 );", + " ", + "" + ], + "* pack" : "append_column", "items" : [ { - "id" : "txtrender", + "$ xns" : "Gtk", "* pack" : "pack_start,true", - "xtype" : "CellRendererText", - "$ xns" : "Gtk" + "id" : "txtrender", + "xtype" : "CellRendererText" } - ] + ], + "utf8 title" : "Drag to add Object", + "xtype" : "TreeViewColumn" } - ] + ], + "listeners" : { + "button_press_event" : [ + " ( event) => {", + "", + " //\tif (!this.get('/Editor').save()) {", + " //\t // popup!! - click handled.. ", + "// \t return true;", + "// }", + " return false;", + "}" + ], + "drag_begin" : [ + " ( ctx) => {", + " // we could fill this in now...", + "// Seed.print('SOURCE: drag-begin');", + " ", + " ", + " ", + " Gtk.TreeIter iter;", + " var s = this.el.get_selection();", + " ", + " Gtk.TreeModel mod;", + " s.get_selected(out mod, out iter);", + " var path = mod.get_path(iter);", + " ", + " /// pix is a surface..", + " var pix = this.el.create_row_drag_icon ( path);", + " ", + " ", + " Gtk.drag_set_icon_surface (ctx, pix);", + " GLib.Value value;", + " ", + "", + " _this.model.el.get_value(iter, 0, out value);", + " ", + " this.dragData = (string) value;", + " ", + " ", + " return;", + "}" + ], + "drag_data_get" : [ + "(drag_context, selection_data, info, time) => {", + " \t//Seed.print('Palete: drag-data-get: ' + target_type);", + " if (this.dragData.length < 1 ) {", + " return; ", + " }", + " ", + " GLib.debug(\"setting drag data to %s\\n\", this.dragData);", + " // selection_data.set_text(this.dragData ,this.dragData.length);", + " selection_data.set (selection_data.get_target (), 8, (uchar[]) this.dragData.to_utf8 ());", + "", + " //this.el.dragData = \"TEST from source widget\";", + " ", + " ", + "}" + ], + "drag_end" : [ + "( drag_context) => {", + " \t GLib.debug(\"SOURCE: drag-end (call listener on this)\\n\");", + "\t", + "\tthis.dragData = \"\";", + "\t//this.dropList = null;", + "\t_this.drag_end(); // call signal..", + "\t//this.get('/LeftTree.view').highlight(false);", + "\t ", + "}" + ] + }, + "xtype" : "TreeView" } - ] + ], + "xtype" : "ScrolledWindow" } - ] + ], + "xtype" : "Box" } + ], + "xtype" : "Box", + "| void clear" : [ + "() {", + " this.model.el.clear();", + "} " + ], + "| void load" : [ + " (Palete.Palete pal, string cls ) {", + " ", + " // this.get('model').expanded();", + " ", + " var tr = pal.getChildList(cls);", + " this.model.el.clear();", + "", + "", + " Gtk.TreeIter citer;", + "", + " for(var i =0 ; i < tr.length; i++) {", + " this.model.el.append(out citer); ", + " var dname = tr[i];", + " if (dname.contains(\":\")) {", + "\t\t\tvar ar = dname.split(\":\");", + "\t\t\tdname = \"\" + ar[1] +\" - \"+ar[0]+\"\";", + "\t\t}", + " ", + " this.model.el.set_value(citer, 0, tr[i] ); // used data. ", + " this.model.el.set_value(citer, 1, dname ); // displayed value.", + " ", + " }", + " this.model.el.set_sort_column_id(1,Gtk.SortType.ASCENDING);", + " ", + "} ", + "", + "" ] } - ] + ], + "modOrder" : "", + "name" : "WindowRightPalete", + "parent" : "", + "path" : "/home/alan/gitlive/roobuilder/src/Builder4/WindowRightPalete.bjs", + "permname" : "", + "title" : "" } \ No newline at end of file diff --git a/src/Builder4/WindowState.vala b/src/Builder4/WindowState.vala index 58a0888ae..01464fd3d 100644 --- a/src/Builder4/WindowState.vala +++ b/src/Builder4/WindowState.vala @@ -12,10 +12,10 @@ public class WindowState : Object public enum State { NONE, PREVIEW, - OBJECT, - PROP, - LISTENER, - CODE, // code editor. + //OBJECT, + //PROP, + //LISTENER, + //CODE, // code editor. CODEONLY, FILES //, @@ -28,15 +28,15 @@ public class WindowState : Object public Project.Project project; public JsRender.JsRender file; - - + public Xcls_WindowLeftTree left_tree; - public Xcls_WindowAddProp add_props; + public Xcls_PopoverAddProp add_props; public Xcls_LeftProps left_props; public Xcls_RooProjectSettings roo_projectsettings_pop; public Xcls_ValaProjectSettingsPopover vala_projectsettings_pop; - public Xcls_RightPalete rightpalete; - public Editor code_editor; + public Xcls_PopoverAddObject rightpalete; + public Xcls_PopoverEditor code_editor_popover; + public Editor code_editor_tab; public Xcls_WindowRooView window_rooview; public Xcls_GtkView window_gladeview; @@ -71,6 +71,7 @@ public class WindowState : Object // on clutter space... this.projectEditInit(); this.codeEditInit(); + this.codePopoverEditInit(); this.projectListInit(); this.fileViewInit(); @@ -157,19 +158,25 @@ public class WindowState : Object public bool leftTreeBeforeChange() { - if (this.state != State.CODE) { + // in theory code editor has to hide before tree change occurs. + //if (this.state != State.CODE) { this.left_props.finish_editing(); return true; - } - if (!this.code_editor.saveContents()) { - return false; - } + //} + + //if (!this.code_editor.saveContents()) { + // return false; + //} return false; } public void leftTreeNodeSelected(JsRender.Node? sel, string source) { - + + // do we really want to flip paletes if differnt nodes are selected + // showing palete should be deliberate thing.. + + print("node_selected called %s\n", (sel == null) ? "NULL" : "a value"); if (sel == null) { @@ -177,35 +184,17 @@ public class WindowState : Object } this.left_props.el.show(); this.left_props.load(this.left_tree.getActiveFile(), sel); - switch (this.state) { - - case State.OBJECT: - - if (sel == null) { - this.rightpalete.clear(); - break; - } - this.rightpalete.load(this.left_tree.getActiveFile().palete(), sel.fqn()); - break; - - case State.PROP: - if (sel == null) { - this.add_props.clear(); - break; - } - this.add_props.show(this.left_tree.getActiveFile().palete(), "props", sel.fqn()); - break; - - case State.LISTENER: - - if (sel == null) { - this.add_props.clear(); - break; - } - this.add_props.show(this.left_tree.getActiveFile().palete(), "signals", sel.fqn()); - break; - + + // if either of these are active.. then we should update them?? + + this.add_props.hide(); // always hide add node/add listener if we change node. + this.rightpalete.hide(); + + + /* + switch (this.state) { + case State.CODE: this.switchState(State.PREVIEW); @@ -213,6 +202,8 @@ public class WindowState : Object } + */ + } @@ -230,8 +221,9 @@ public class WindowState : Object this.left_props.el.show_all(); this.left_props.show_editor.connect( (file, node, type, key) => { - this.switchState(State.CODE); - this.code_editor.show( + //this.switchState(State.CODE); + this.code_editor_popover.show( + this.left_props.el, file, node, type, @@ -241,17 +233,17 @@ public class WindowState : Object }); - + // not sure if this is needed - as closing the popvoer should save it. this.left_props.stop_editor.connect( () => { - if (this.state != State.CODE) { - return true; - } + //if (this.state != State.CODE) { + // return true; + //} - var ret = this.code_editor.saveContents(); + var ret = this.code_editor_popover.editor.saveContents(); if (!ret) { return false; } - this.switchState(State.PREVIEW); + //this.switchState(State.PREVIEW); return ret; }); @@ -341,14 +333,15 @@ public class WindowState : Object public void objectAddInit() { - this.rightpalete = new Xcls_RightPalete(); + this.rightpalete = new Xcls_PopoverAddObject(); + this.rightpalete.mainwindow = this.win; this.rightpalete.ref(); /// really? - ((Gtk.Container)(this.win.objectview.el.get_widget())).add(this.rightpalete.el); + /*((Gtk.Container)(this.win.objectview.el.get_widget())).add(this.rightpalete.el); var stage = this.win.objectview.el.get_stage(); stage.set_background_color( Clutter.Color.from_string("#000")); - + */ } // ----------- properties adding list... @@ -356,16 +349,19 @@ public class WindowState : Object public void propsAddInit() { // Add properties - this.add_props = new Xcls_WindowAddProp(); + this.add_props = new Xcls_PopoverAddProp(); + this.add_props.mainwindow = this.win; this.add_props.ref(); /// really? - ((Gtk.Container)(this.win.addpropsview.el.get_widget())).add(this.add_props.el); + // don't need to add it.. + //((Gtk.Container)(this.win.addpropsview.el.get_widget())).add(this.add_props.el); - var stage = this.win.addpropsview.el.get_stage(); - stage.set_background_color( Clutter.Color.from_string("#000")); + //var stage = this.win.addpropsview.el.get_stage(); + //stage.set_background_color( Clutter.Color.from_string("#000")); this.add_props.select.connect( (key,type,skel, etype) => { + this.left_props.addProp(etype, key, skel, type); }); @@ -379,9 +375,7 @@ public class WindowState : Object } - - - + // ----------- Add / Edit listener // listener uses the properties //public void listenerInit() { } @@ -398,18 +392,38 @@ public class WindowState : Object public void codeEditInit() { - this.code_editor = new Editor(); + this.code_editor_tab = new Editor(); //this.code_editor.ref(); /// really? - ((Gtk.Container)(this.win.codeeditview.el.get_widget())).add(this.code_editor.el); + ((Gtk.Container)(this.win.codeeditview.el.get_widget())).add(this.code_editor_tab.el); - this.code_editor.window = this.win; + this.code_editor_tab.window = this.win; var stage = this.win.codeeditview.el.get_stage(); stage.set_background_color( Clutter.Color.from_string("#000")); // editor.save... - this.code_editor.save.connect( () => { + this.code_editor_tab.save.connect( () => { + this.file.save(); + this.left_tree.model.updateSelected(); + if (this.left_tree.getActiveFile().xtype == "Roo" ) { + this.window_rooview.requestRedraw(); + } else { + this.window_gladeview.loadFile(this.left_tree.getActiveFile()); + } + // we do not need to call spawn... - as it's already called by the editor? + + }); + + } + public void codePopoverEditInit() + { + this.code_editor_popover = new Xcls_PopoverEditor(); + //this.code_editor.ref(); /// really? + + this.code_editor_popover.setMainWindow( this.win); + + this.code_editor_popover.editor.save.connect( () => { this.file.save(); this.left_tree.model.updateSelected(); if (this.left_tree.getActiveFile().xtype == "Roo" ) { @@ -422,7 +436,6 @@ public class WindowState : Object }); } - // ----------- list of projects on left public void projectListInit() { @@ -488,9 +501,9 @@ public class WindowState : Object if (file.xtype == "PlainFile") { this.switchState (State.CODEONLY); file.loadItems(); - this.code_editor.show(file, null, "", ""); + this.code_editor_tab.show(file, null, "", ""); if (line> -1) { - this.code_editor.scroll_to_line(line); + this.code_editor_tab.scroll_to_line(line); } } else { @@ -589,6 +602,42 @@ public class WindowState : Object this.clutterfiles.el.restore_easing_state(); } + + + public void showProps(Gtk.Widget btn, string sig_or_listen) + { + var ae = this.left_tree.getActiveElement(); + if (ae == null) { + return; + } + this.rightpalete.hide(); + + this.add_props.el.show_all(); + this.add_props.show( + this.win.project.palete, //Palete.factory(this.win.project.xtype), + sig_or_listen, //this.state == State.LISTENER ? "signals" : "props", + ae.fqn(), + btn + + ); + } + + public void showAddObject(Gtk.Widget btn) + { + + var n = this.left_tree.getActiveElement(); + this.add_props.hide(); + this.rightpalete.el.show_all(); + this.rightpalete.show( + this.left_tree.getActiveFile().palete(), + n == null ? "*top" : n.fqn(), + btn + ); + } + + + + public void switchState(State new_state) { @@ -623,18 +672,8 @@ public class WindowState : Object break; - - case State.LISTENER: - case State.PROP: - - this.win.addpropsview.el.set_scale(0.0f,0.0f); - break; - - case State.CODE: - this.code_editor.saveContents(); - - this.win.codeeditview.el.set_scale(0.0f,0.0f); - break; + + case State.CODEONLY: // going from codeonly.. @@ -647,12 +686,7 @@ public class WindowState : Object this.win.leftpane.el.show(); this.win.codeeditview.el.set_scale(0.0f,0.0f); - /*this.win.codeeditview.el.set_easing_duration(1000); - this.win.codeeditview.el.set_rotation_angle(Clutter.RotateAxis.Y_AXIS, 0.0f); - //this.win.codeeditview.el.set_scale(1.0f,1.0f); - this.win.codeeditview.el.set_pivot_point(0.5f,0.5f); - this.win.codeeditview.el.set_opacity(0xff); - */ + while (Gtk.events_pending()) { Gtk.main_iteration(); @@ -662,36 +696,11 @@ public class WindowState : Object break; - case State.OBJECT: - - this.win.objectview.el.set_scale(0.0f,0.0f); - break; - - /*case State.FILEPROJECT: - //case State.PROJECT: - //case State.PROJECTCODEONLY: - if (this.win.project.xtype == "Gtk") { - this.vala_projectsettings.save(); - } - if (this.state == State.FILEPROJECT) { - this.clutterfiles.el.set_scale(1.0f,1.0f); - - } - this.win.projecteditview.el.set_scale(0.0f,0.0f); - break; - */ + case State.FILES: // goes to preview or codeonly... // hide files... - - /*if (new_state == State.FILEPROJECT) { - - this.clutterfiles.el.set_easing_duration(1000); - this.clutterfiles.el.set_pivot_point(0.5f,1.0f); - this.clutterfiles.el.set_scale(0.5f,0.5f); - break; - } - */ + if (new_state == State.CODEONLY) { this.win.rooview.el.hide(); @@ -743,74 +752,9 @@ public class WindowState : Object } break; - - - case State.LISTENER: - // same as prop? - case State.PROP: - var ae = this.left_tree.getActiveElement(); - if (ae == null) { - this.state = oldstate; - this.buttonsShowHide(); - this.resizeCanvasElements(); - this.easingRestoreAll(); - return; - } - this.add_props.el.show_all(); - this.add_props.show( - this.win.project.palete, //Palete.factory(this.win.project.xtype), - this.state == State.LISTENER ? "signals" : "props", - ae.fqn() - ); - - - - // -- FIXME? this needs to be State aware? - this.win.rooview.el.set_pivot_point(1.0f,0.5f); - - this.win.addpropsview.el.set_scale(1.0f,1.0f); - break; - - case State.OBJECT: - var n = this.left_tree.getActiveElement(); - - if (this.file == null) { - this.state =oldstate; - this.buttonsShowHide(); - this.resizeCanvasElements(); - this.easingRestoreAll(); - return; - } - - if (n == null && this.file.tree != null) { - this.state = oldstate; - this.buttonsShowHide(); - this.resizeCanvasElements(); - this.easingRestoreAll(); - return; - } - - this.rightpalete.el.show_all(); - this.rightpalete.load(this.left_tree.getActiveFile().palete(), n == null ? "*top" : n.fqn()); - - - - this.win.rooview.el.set_pivot_point(1.0f,0.5f); - this.win.objectview.el.set_scale(1.0f,1.0f); - - break; - - - case State.CODE: - this.win.codeeditview.el.show(); - this.code_editor.el.show_all(); - // caller needs to call editor - show.... - this.win.codeeditview.el.set_scale(1.0f,1.0f); - this.win.rooview.el.set_pivot_point(1.0f,0.5f); - - break; + case State.CODEONLY: // going to codeonly.. @@ -827,65 +771,13 @@ public class WindowState : Object //} - this.code_editor.el.show_all(); + this.code_editor_tab.el.show_all(); this.win.codeeditview.el.set_scale(1.0f,1.0f); this.win.rooview.el.set_pivot_point(1.0f,0.5f); break; - /*case State.PROJECTCODEONLY: - // going to project edit (when in code only) - - - - if (this.win.project.xtype == "Roo") { - this.projectsettings.el.show_all(); - this.projectsettings.show(this.win.project); - } else { - this.vala_projectsettings.el.show_all(); - this.vala_projectsettings.show((Project.Gtk)this.win.project); - } - - this.win.projecteditview.el.set_scale(1.0f,1.0f); - - break; - - - case State.PROJECT: - this.win.rooview.el.set_pivot_point(1.0f,1.0f); // bottom right.. - - if (this.win.project.xtype == "Roo") { - this.projectsettings.el.show_all(); - this.projectsettings.show(this.win.project); - } else { - this.vala_projectsettings.el.show_all(); - this.vala_projectsettings.show((Project.Gtk)this.win.project); - } - - this.win.projecteditview.el.set_scale(1.0f,1.0f); - - break; - - case State.FILEPROJECT: - var pr = this.left_projects.getSelectedProject(); - - this.win.project = pr; - - this.attachProjectSettings(); - print("FIlE PROJECT - show %s\n", pr.xtype); - - if (pr.xtype == "Roo") { - this.projectsettings.el.show_all(); - this.projectsettings.show(this.win.project); - } else { - this.vala_projectsettings.el.show_all(); - this.vala_projectsettings.show((Project.Gtk)this.win.project); - } - - this.win.projecteditview.el.set_scale(1.0f,1.0f); - - break; - */ + case State.FILES: // can only get here from PREVIEW (or code-only) state.. in theory.. @@ -996,25 +888,7 @@ public class WindowState : Object this.clutterfiles.set_size(alloc.width-50, alloc.height); break; - /*case State.PROJECT: - - this.win.projecteditview.el.set_size(alloc.width-50, alloc.height / 2.0f); - - // this.win.rooview.el.save_easing_state(); - //this.win.rooview.el.set_size(alloc.width / 2.0f, alloc.height / 2.0f); - - this.win.rooview.el.set_scale(0.5f, 0.5f); - //this.win.rooview.el.restore_easing_state(); - break; - */ - case State.CODE: - this.win.codeeditview.el.set_size(codesize, alloc.height); - var scale = avail > 0.0f ? (avail - codesize -10 ) / avail : 0.0f; - //this.win.rooview.el.save_easing_state(); - - this.win.rooview.el.set_scale(scale,scale); - // this.win.rooview.el.restore_easing_state(); - break; + case State.CODEONLY: this.win.codeeditview.el.set_size(codesize, alloc.height); @@ -1024,20 +898,7 @@ public class WindowState : Object this.win.rooview.el.set_scale(scale,scale); // this.win.rooview.el.restore_easing_state(); break; - case State.PROP: - case State.LISTENER: - this.win.addpropsview.el.set_size(palsize, alloc.height); - var scale = avail > 0.0f ? (avail - palsize -10 ) / avail : 0.0f; - this.win.rooview.el.set_scale(scale,scale); - break; - - case State.OBJECT: - this.win.objectview.el.set_size(palsize, alloc.height); - var scale = avail > 0.0f ? (avail - palsize -10 ) / avail : 0.0f; - //this.win.rooview.el.save_easing_state(); - this.win.rooview.el.set_scale(scale,scale); - // this.win.rooview.el.restore_easing_state(); - break; + } } @@ -1094,34 +955,9 @@ public class WindowState : Object this.win.projecteditbutton.el.show(); this.win.search_entry.el.show(); break; - - case State.CODE: - this.win.search_entry.el.show(); - this.win.backbutton.el.show(); - this.win.objectshowbutton.el.show(); // add objects ?? can you do this from here? - this.win.addpropbutton.el.show(); - this.win.addlistenerbutton.el.show(); - break; - // continue thru.. - case State.PROP: - case State.LISTENER: - case State.OBJECT: - - this.win.backbutton.el.show(); - this.win.objectshowbutton.el.show(); // add objects - this.win.addpropbutton.el.show(); - this.win.addlistenerbutton.el.show(); - break; - /* - case State.PROJECT: - case State.FILEPROJECT: - case State.PROJECTCODEONLY: - // anything else? - this.win.backbutton.el.show(); - - break; - */ - + + + case State.FILES: if (this.left_projects.getSelectedProject() != null ) { if (this.left_tree.getActiveFile() != null) { @@ -1162,7 +998,7 @@ public class WindowState : Object print("result :%s", generator.to_data (null)); - var buf = this.code_editor.buffer; + var buf = this.code_editor_tab.buffer; buf.check_running = false; var has_errors = false; @@ -1190,7 +1026,7 @@ public class WindowState : Object this.win.statusbar_depricated.setNotices( new Json.Object(),0); } //if (this.state == State.CODE || this.state == State.PROJECTCODEONLY) { - if (this.state == State.CODE || this.state == State.CODEONLY) { + if ( this.state == State.CODEONLY) { buf.highlightErrorsJson("ERR", obj); buf.highlightErrorsJson("WARN", obj); buf.highlightErrorsJson("DEPR", obj); diff --git a/src/Builder4/config1.builder b/src/Builder4/config1.builder index 78a953956..2fdb838bf 100644 --- a/src/Builder4/config1.builder +++ b/src/Builder4/config1.builder @@ -12,18 +12,15 @@ "../Builder4/DialogSaveModule.vala", "../Builder4/DialogSaveTemplate.vala", "../Builder4/DialogTemplateSelect.vala", - "../Builder4/Editor.vala", "../Builder4/EditProject.vala", "../Builder4/FakeServer.vala", "../Builder4/GtkView.vala", "../Builder4/MainWindow.vala", "../Builder4/RooProjectProperties.vala", "../Builder4/StandardErrorDialog.vala", - "../Builder4/WindowAddProp.vala", "../Builder4/WindowLeftProjects.vala", "../Builder4/WindowLeftProps.vala", "../Builder4/WindowLeftTree.vala", - "../Builder4/WindowRightPalete.vala", "../Builder4/WindowRooView.vala", "../Builder4/WindowState.vala", "../Builder4", @@ -156,7 +153,11 @@ "..//ccode/valaccodevariabledeclarator.vala", "..//ccode/valaccodewhilestatement.vala", "..//ccode/valaccodewriter.vala", - "..//ccode" + "..//ccode", + "../Builder4/PopoverAddProp.vala", + "../Builder4/PopoverAddObject.vala", + "../Builder4/PopoverEditor.vala", + "../Builder4/Editor.vala" ], "packages" : [] }, diff --git a/src/Makefile.am b/src/Makefile.am index 11726cd98..09ed38aef 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -208,14 +208,15 @@ BUIDERUI = Builder4/About.vala \ Builder4/DialogTemplateSelect.vala \ Builder4/EditProject.vala \ Builder4/Editor.vala \ + Builder4/PopoverEditor.vala \ Builder4/RooProjectSettings.vala \ - Builder4/WindowRightPalete.vala \ + Builder4/PopoverAddObject.vala \ Builder4/WindowLeftTree.vala \ Builder4/WindowRooView.vala \ Builder4/WindowLeftProps.vala \ Builder4/ClutterFiles.vala \ Builder4/WindowLeftProjects.vala \ - Builder4/WindowAddProp.vala \ + Builder4/PopoverAddProp.vala \ Builder4/GtkView.vala \ Builder4/ValaProjectSettingsPopover.vala \ Builder4/MainWindow.vala \ -- 2.39.2