From a35c122c4cd604f9f9620a435338ec54c8faecd9 Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Tue, 7 Jun 2016 15:39:37 +0800 Subject: [PATCH] src/Builder4/WindowRooView.bjs src/Builder4/WindowRooView.vala --- src/Builder4/WindowRooView.bjs | 24 ++++++++++++------------ src/Builder4/WindowRooView.vala | 4 ++++ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/Builder4/WindowRooView.bjs b/src/Builder4/WindowRooView.bjs index c4b159060..d9847bcdc 100644 --- a/src/Builder4/WindowRooView.bjs +++ b/src/Builder4/WindowRooView.bjs @@ -29,43 +29,43 @@ "items" : [ { "id" : "notebook", - "xtype" : "Notebook", "* pack" : "pack_start,true,true,0", + "xtype" : "Notebook", "$ xns" : "Gtk", "items" : [ { "id" : "label_preview", - "xtype" : "Label", "* pack" : false, + "xtype" : "Label", "$ xns" : "Gtk", "utf8 label" : "Preview" }, { "id" : "label_code", - "* pack" : false, "xtype" : "Label", + "* pack" : false, "$ xns" : "Gtk", "utf8 label" : "Preview Generated Code" }, { "id" : "paned", - "xtype" : "Paned", "* pack" : "add", + "xtype" : "Paned", "$ xns" : "Gtk", "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", "items" : [ { "id" : "viewbox", - "xtype" : "Box", "* pack" : "pack1,true,true", + "xtype" : "Box", "$ xns" : "Gtk", "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", "$ homogeneous" : false, "items" : [ { "$ vexpand" : false, - "* pack" : "pack_start,false,true,0", "$ height_request" : 20, + "* pack" : "pack_start,false,true,0", "xtype" : "Box", "$ xns" : "Gtk", "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL", @@ -76,8 +76,8 @@ "clicked" : "( ) => {\n _this.view.renderJS( true);\n}" }, "label" : "Redraw", - "* pack" : "pack_start,false,false,0", "xtype" : "Button", + "* pack" : "pack_start,false,false,0", "$ xns" : "Gtk" }, { @@ -96,16 +96,16 @@ "clicked" : " () => {\n _this.view.redraws = 99;\n _this.view.el.web_context.clear_cache(); \n //_this.view.renderJS(true);\n FakeServerCache.clear();\n _this.view.reInit();\n\n}" }, "label" : "Full Redraw", - "* pack" : "pack_start,false,false,0", "xtype" : "Button", + "* pack" : "pack_start,false,false,0", "$ xns" : "Gtk" } ] }, { "id" : "viewcontainer", - "$ shadow_type" : "Gtk.ShadowType.IN", "* init" : " this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n \n", + "$ shadow_type" : "Gtk.ShadowType.IN", "* pack" : "pack_end,true,true,0", "xtype" : "ScrolledWindow", "$ xns" : "Gtk", @@ -142,8 +142,8 @@ }, { "id" : "inspectorcontainer", - "$ shadow_type" : "Gtk.ShadowType.IN", "* init" : " this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n \n", + "$ shadow_type" : "Gtk.ShadowType.IN", "xtype" : "ScrolledWindow", "* pack" : "pack2,true,true", "$ xns" : "Gtk" @@ -160,8 +160,8 @@ "button_release_event" : "() => {\n\tthis.onCursorChanged();\n\n\treturn false;\n}" }, "gboolean show_line_marks" : true, - "| void onCursorChanged" : "(/*ParamSpec ps*/) {\n\t if (this.loading) {\n return;\n }\n // if (ps.name != \"cursor-position\") {\n // return;\n // }\n\n var buf = this.el.get_buffer();\n print(\"cursor changed : %d\\n\", buf.cursor_position);\n Gtk.TextIter cpos;\n buf.get_iter_at_offset(out cpos, buf.cursor_position);\n \n var ln = cpos.get_line();\n\t\tprint(\"cursor changed line : %d\\n\", ln);\n var node = _this.file.lineToNode(ln+1);\n \n if (node == null) {\n print(\"can not find node\\n\");\n return;\n }\n var prop = node.lineToProp(ln+1);\n print(\"prop : %s\", prop == null ? \"???\" : prop);\n \n \n \n \n \n \n var ltree = _this.main_window.windowstate.left_tree;\n var tp = ltree.model.treePathFromNode(node);\n print(\"got tree path %s\\n\", tp);\n if (tp != \"\") {\n\t this.allow_node_scroll = false; /// block node scrolling..\n\t \n\t \n\t //print(\"changing cursor on tree..\\n\");\n\t \n \n \n // let's try allowing editing on the methods.\n // a little klunky at present..\n this.propSelected = \"\";\n if (prop != null) {\n \t\t//see if we can find it..\n \t\tvar kv = prop.split(\":\");\n \t\tif (kv[0] == \"p\") {\n \t\t\n\t \t\t//var k = prop.get_key(kv[1]);\n\t \t\t// fixme -- need to determine if it's an editable property...\n\t \t\tthis.propSelected = prop;\n\t \t\t\n \t\t} else if (kv[0] == \"l\") {\n \t\t\t this.propSelected = prop;\n \t\t\t\n \t\t}\n }\n ltree.view.setCursor(tp, \"editor\");\n // ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false); \n this.nodeSelected(node,false);\n \n // scrolling is disabled... as node selection calls scroll 10ms after it changes.\n GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => {\n\t this.allow_node_scroll = true;\n\t return false;\n });\n }\n \n // highlight the node..\n}\n ", "id" : "sourceview", + "| void onCursorChanged" : "(/*ParamSpec ps*/) {\n\t if (this.loading) {\n return;\n }\n // if (ps.name != \"cursor-position\") {\n // return;\n // }\n\n var buf = this.el.get_buffer();\n print(\"cursor changed : %d\\n\", buf.cursor_position);\n Gtk.TextIter cpos;\n buf.get_iter_at_offset(out cpos, buf.cursor_position);\n \n var ln = cpos.get_line();\n\t\tprint(\"cursor changed line : %d\\n\", ln);\n var node = _this.file.lineToNode(ln+1);\n \n if (node == null) {\n print(\"can not find node\\n\");\n return;\n }\n var prop = node.lineToProp(ln+1);\n print(\"prop : %s\", prop == null ? \"???\" : prop);\n \n \n \n \n \n \n var ltree = _this.main_window.windowstate.left_tree;\n var tp = ltree.model.treePathFromNode(node);\n print(\"got tree path %s\\n\", tp);\n if (tp != \"\") {\n\t this.allow_node_scroll = false; /// block node scrolling..\n\t \n\t \n\t //print(\"changing cursor on tree..\\n\");\n\t \n \n \n // let's try allowing editing on the methods.\n // a little klunky at present..\n this.propSelected = \"\";\n if (prop != null) {\n \t\t//see if we can find it..\n \t\tvar kv = prop.split(\":\");\n \t\tif (kv[0] == \"p\") {\n \t\t\n\t \t\t//var k = prop.get_key(kv[1]);\n\t \t\t// fixme -- need to determine if it's an editable property...\n\t \t\tthis.propSelected = prop;\n\t \t\t\n \t\t} else if (kv[0] == \"l\") {\n \t\t\t this.propSelected = prop;\n \t\t\t\n \t\t}\n }\n ltree.view.setCursor(tp, \"editor\");\n // ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false); \n this.nodeSelected(node,false);\n \n // scrolling is disabled... as node selection calls scroll 10ms after it changes.\n GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => {\n\t this.allow_node_scroll = true;\n\t return false;\n });\n }\n \n // highlight the node..\n}\n ", "* init" : "{\n \n var description = Pango.FontDescription.from_string(\"monospace\");\n description.set_size(8000);\n this.el.override_font(description);\n\n this.loading = true;\n //var buf = this.el.get_buffer();\n //buf.notify.connect(this.onCursorChanged);\n \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 \n var gattrs = new Gtk.SourceMarkAttributes();\n var grey = Gdk.RGBA();\n grey.parse ( \"#ccc\");\n gattrs.set_background ( grey);\n \n \n this.el.set_mark_attributes (\"grey\", gattrs, 1);\n \n \n \n \n \n \n}\n ", "| void nodeSelected" : "(JsRender.Node? sel, bool scroll ) {\n \n \n \n // this is connected in widnowstate\n print(\"node selected\\n\");\n var buf = this.el.get_buffer();\n \n var sbuf = (Gtk.SourceBuffer) buf;\n\n \n while(Gtk.events_pending()) {\n Gtk.main_iteration();\n }\n \n \n // clear all the marks..\n Gtk.TextIter start;\n Gtk.TextIter end; \n \n sbuf.get_bounds (out start, out end);\n sbuf.remove_source_marks (start, end, \"grey\");\n \n \n if (sel == null) {\n\t print(\"no selected node\\n\");\n // no highlighting..\n return;\n }\n \n print(\"highlight region %d to %d\\n\", sel.line_start,sel.line_end);\n Gtk.TextIter iter; \n sbuf.get_iter_at_line(out iter, sel.line_start);\n \n \n Gtk.TextIter cur_iter;\n sbuf.get_iter_at_offset(out cur_iter, sbuf.cursor_position);\n \n //var cur_line = cur_iter.get_line();\n //if (cur_line > sel.line_start && cur_line < sel.line_end) {\n \n //} else {\n if (scroll) {\n\t\tprint(\"scrolling to node -- should occur on node picking.\\n\");\n \tthis.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);\n\t}\n \n var start_line = sel.line_start;\n var end_line = sel.line_end;\n \n \n this.el.editable = false;\n // now if we have selected a property...\n if (this.propSelected.length> 0 ) {\n\n\t\tint nstart, nend;\n\t\tif (sel.getPropertyRange(this.propSelected, out nstart, out nend) && nend > nstart) {\n\t\t\tstart_line = nstart;\n\t\t\tend_line = nend;\n\t\t\tthis.el.editable = true;\n\t\t}\n\t\tprint(\"propSelected = %s range %d -> %d\\n\", this.propSelected, start_line, end_line);\t\t\n\t\t\n\t\t\n }\n \n // check selection - if it's out of 'bounds'\n if (this.el.editable && sbuf.get_has_selection()) {\n\t\tGtk.TextIter sel_start_iter, sel_end_iter;\n\t\tsbuf.get_selection_bounds(out sel_start_iter, out sel_end_iter);\n\t\t\n\t\tif (sel_start_iter.get_line() < start_line || sel_end_iter.get_line() > end_line ||\n\t\t\tsel_start_iter.get_line() > end_line || sel_end_iter.get_line() < start_line\t\t\t) {\n\t\t\t// save?\n\t\t\tthis.el.editable = false;\n\t\t}\n \n }\n \n \n \n \n for (var i = 0; i < buf.get_line_count();i++) {\n if (i < (start_line -1) || i > (end_line -1)) {\n \n sbuf.get_iter_at_line(out iter, i);\n sbuf.create_source_mark(null, \"grey\", iter);\n \n }\n \n }\n \n\n}\n", "bool loading" : true, @@ -178,7 +178,7 @@ "items" : [ { "listeners" : { - "changed" : " () => {\n // check syntax??\n // ??needed..??\n // _this.save_button.el.sensitive = true;\n ///?? has changed occured during loading?\n print(\"- PREVIEW EDITOR CHANGED--\");\n \n \n //this.checkSyntax();\n \n this.dirty = true;\n\n\n return ;\n}\n\n \n" + "changed" : " () => {\n // check syntax??\n // ??needed..??\n // _this.save_button.el.sensitive = true;\n ///?? has changed occured during loading?\n if (_this.sourceview.loading) {\n\t\treturn;\n\t}\n\t\n print(\"- PREVIEW EDITOR CHANGED--\");\n \n \n //this.checkSyntax();\n \n this.dirty = true;\n\n\n return ;\n}\n\n \n" }, "bool check_queued" : false, "bool dirty" : false, diff --git a/src/Builder4/WindowRooView.vala b/src/Builder4/WindowRooView.vala index 42b874cc1..49a0d208e 100644 --- a/src/Builder4/WindowRooView.vala +++ b/src/Builder4/WindowRooView.vala @@ -1371,6 +1371,10 @@ public class Xcls_WindowRooView : Object // ??needed..?? // _this.save_button.el.sensitive = true; ///?? has changed occured during loading? + if (_this.sourceview.loading) { + return; + } + print("- PREVIEW EDITOR CHANGED--"); -- 2.39.2