-SUBDIRS = src
\ No newline at end of file
+SUBDIRS = src
+
+desktopdir = $(datadir)/applications
+desktop_DATA =builder4.desktop
\ No newline at end of file
--- /dev/null
+[Desktop Entry]
+Version=1.0
+Encoding=UTF-8
+Name=Roo JS Builder
+Comment=Vala and Javascript Application Biuilder
+Exec=builder4
+Icon=application-default-icon
+Terminal=false
+Type=Application
+StartupNotify=true
+Categories=GNOME;GTK;Utility;
\ No newline at end of file
dnl --- libvala -- needs to find matching really..
-
-PKG_CHECK_MODULES(LIBVALA, [libvala-0.30],
- [vala_3_0_enabled=yes],
- [vala_3_0_enabled=no])
-if test $vala_3_0_enabled = yes; then
- AC_DEFINE(HAVE_LIBVALA30,1,[libvala 0.30 support])
-else
- PKG_CHECK_MODULES(LIBVALA, [libvala-0.28],
- [vala_2_8_enabled=yes],
- [vala_2_8_enabled=no])
- if test $vala_2_8_enabled = yes; then
- AC_DEFINE(HAVE_LIBVALA28,1,[libvala 0.28 support])
- else
- PKG_CHECK_MODULES(LIBVALA, [libvala-0.26],
- [vala_2_6_enabled=yes],
- [vala_2_6_enabled=no])
-
- if test $vala_2_6_enabled = yes; then
- AC_DEFINE(HAVE_LIBVALA26,1,[libvala 0.26 support])
- else
- PKG_CHECK_MODULES(LIBVALA, [libvala-0.24],
- [vala_2_4_enabled=yes],
- [vala_2_4_enabled=no])
-
- if test $vala_2_4_enabled = yes; then
- AC_DEFINE(HAVE_LIBVALA24,1,[libvala 0.24 support])
- else
- PKG_CHECK_MODULES(LIBVALA, [libvala-0.22],
- [vala_2_2_enabled=yes] )
-
- AC_DEFINE(HAVE_LIBVALA22,1,[libvala 0.22 support])
- fi
- fi
+PKG_CHECK_MODULES(LIBVALA, [libvala-0.32],
+ [vala_3_2_enabled=yes],
+ [vala_3_2_enabled=no])
+if test $vala_3_2_enabled = yes; then
+ AC_DEFINE(HAVE_LIBVALA32,1,[libvala 0.32 support])
+else
+ PKG_CHECK_MODULES(LIBVALA, [libvala-0.30],
+ [vala_3_0_enabled=yes],
+ [vala_3_0_enabled=no])
+ if test $vala_3_0_enabled = yes; then
+ AC_DEFINE(HAVE_LIBVALA30,1,[libvala 0.30 support])
+ else
+ PKG_CHECK_MODULES(LIBVALA, [libvala-0.28],
+ [vala_2_8_enabled=yes],
+ [vala_2_8_enabled=no])
+ if test $vala_2_8_enabled = yes; then
+ AC_DEFINE(HAVE_LIBVALA28,1,[libvala 0.28 support])
+ else
+ PKG_CHECK_MODULES(LIBVALA, [libvala-0.26],
+ [vala_2_6_enabled=yes],
+ [vala_2_6_enabled=no])
+
+ if test $vala_2_6_enabled = yes; then
+ AC_DEFINE(HAVE_LIBVALA26,1,[libvala 0.26 support])
+ else
+ PKG_CHECK_MODULES(LIBVALA, [libvala-0.24],
+ [vala_2_4_enabled=yes],
+ [vala_2_4_enabled=no])
+
+ if test $vala_2_4_enabled = yes; then
+ AC_DEFINE(HAVE_LIBVALA24,1,[libvala 0.24 support])
+ else
+ PKG_CHECK_MODULES(LIBVALA, [libvala-0.22],
+ [vala_2_2_enabled=yes] )
+
+ AC_DEFINE(HAVE_LIBVALA22,1,[libvala 0.22 support])
+ fi
+ fi
+ fi
fi
fi
+AM_CONDITIONAL(HAVE_LIBVALA30, test "$vala_3_2_enabled" = "yes")
AM_CONDITIONAL(HAVE_LIBVALA30, test "$vala_3_0_enabled" = "yes")
AM_CONDITIONAL(HAVE_LIBVALA28, test "$vala_2_8_enabled" = "yes")
AM_CONDITIONAL(HAVE_LIBVALA26, test "$vala_2_6_enabled" = "yes")
{ "add-file", 0, 0, OptionArg.STRING, ref opt_compile_add, "Add this file to compile list", null },
{ "output", 0, 0, OptionArg.STRING, ref opt_compile_output, "output binary file path", null },
{ "debug", 0, 0, OptionArg.NONE, ref opt_debug, "Show debug messages", null },
+
+ // some testing code.
+ { "list-projects", 0, 0, OptionArg.NONE, ref opt_list_projects, "List Projects", null },
+ { "list-files", 0, 0, OptionArg.NONE, ref opt_list_files, "List Files (in a project", null},
+ { "bjs", 0, 0, OptionArg.STRING, ref opt_bjs_compile, "convert bjs file", null },
+ { "bjs-target", 0, 0, OptionArg.STRING, ref opt_bjs_compile_target, "convert bjs file to tareet : vala / js", null },
+
+
{ null }
};
public static string opt_compile_project;
public static string opt_compile_target;
public static string opt_compile_skip;
public static string opt_compile_add;
- public static string opt_compile_output;
+ public static string opt_compile_output;
+ public static string opt_bjs_compile;
+ public static string opt_bjs_compile_target;
public static bool opt_debug = false;
+ public static bool opt_list_projects = false;
+ public static bool opt_list_files = false;
public static string _self;
"items" : [
{
"# bool allow_edit" : false,
- "| void updateKey" : "(string oldkey, string type, string key ) {\n\n \n\t\n\t_this.model.el.foreach((mod, path, iter) => {\n\t\t \n \n \t \n \n\t\t GLib.Value gvaltype, gval,kvalue;\n\t\t mod.get_value(iter, 1 , out gval); // one is key..\n\t\t\n\t mod.get_value(iter,0, out gvaltype);\n\t \n \t mod.get_value(iter,3, out kvalue);\n\t \n\t if (oldkey == ((string)gval) && type == ((string)gvaltype)) {\n\t \n\t\t \t print(\"update iter type=%s, key=%s value=%s\\n\", type, key,(string) kvalue);\n\t \n \t \t this.updateIter(iter, type, key, (string)kvalue);\n \t \t return true;\n\t \t }\n\t \n\n\t\treturn false;\n\t});\n\t\n\tthis.changed();\n\n\n}\n",
+ "| void updateKey" : "(string oldkey, string type, string key ) {\n\n \n\t\n\t_this.model.el.foreach((mod, path, iter) => {\n\t\t \n \n \t \n \n\t\t GLib.Value gvaltype, gval,kvalue;\n\t\t mod.get_value(iter, 1 , out gval); // one is key..\n\t\t\n\t mod.get_value(iter,0, out gvaltype);\n\t \n \t mod.get_value(iter,3, out kvalue);\n\t \n\t if (oldkey == ((string)gval) && type == ((string)gvaltype)) {\n\t \n\t\t \t //print(\"update iter type=%s, key=%s value=%s\\n\", type, key,(string) kvalue);\n\t \n \t \t this.updateIter(iter, type, key, (string)kvalue);\n \t \t return true;\n\t \t }\n\t \n\n\t\treturn false;\n\t});\n\t\n\tthis.changed();\n\n\n}\n",
"id" : "LeftProps",
"| void before_edit" : "()\n{\n\n print(\"before edit - stop editing\\n\");\n \n // these do not appear to trigger save...\n _this.keyrender.el.stop_editing(false);\n _this.keyrender.el.editable =false;\n\n _this.valrender.el.stop_editing(false);\n _this.valrender.el.editable =false; \n \n \n// technicall stop the popup editor..\n\n}\n",
"| string keySortFormat" : "(string key) {\n // listeners first - with 0\n // specials\n if (key[0] == '*') {\n return \"1 \" + key;\n }\n // functions\n \n var bits = key.split(\" \");\n \n if (key[0] == '|') {\n return \"2 \" + bits[bits.length -1];\n }\n // signals\n if (key[0] == '@') {\n return \"3 \" + bits[bits.length -1];\n }\n \n // props\n if (key[0] == '#') {\n return \"4 \" + bits[bits.length -1];\n }\n // the rest..\n return \"5 \" + bits[bits.length -1]; \n\n\n\n}",
"$ homogeneous" : "false ",
"# Xcls_MainWindow main_window" : "null",
"| void addProp" : " (string in_type, string key, string value, string value_type) {\n // info includes key, val, skel, etype..\n //console.dump(info);\n //type = info.type.toLowerCase();\n //var data = this.toJS();\n \n var type = in_type == \"signals\" ? \"listener\" : in_type;\n \n var fkey = (value_type.length > 0 ? value_type + \" \" : \"\") + key;\n \n if (type == \"listener\") {\n if (this.node.listeners.has_key(key)) {\n return;\n }\n this.node.listeners.set(key,value);\n } else {\n \n if (this.node.props.has_key(fkey)) {\n return;\n }\n this.node.props.set(fkey,value);\n }\n \n \n // add a row???\n this.load(this.file, this.node);\n \n \n \n /// need to find the row which I've just added..\n \n \n var s = this.view.el.get_selection();\n s.unselect_all();\n \n print(\"trying to find new iter\");\n \n this.model.el.foreach((model, path, iter) => {\n GLib.Value gval;\n \n this.model.el.get_value(iter, 0 , out gval);\n if ((string)gval != type) {\n print(\"not type: %s = %s\\n\", (string)gval , type);\n return false;\n }\n this.model.el.get_value(iter, 1 , out gval);\n if ((string)gval != fkey) {\n print(\"not key: %s = %s\\n\", (string)gval , fkey);\n return false;\n }\n // delay this?\n GLib.Timeout.add_full(GLib.Priority.DEFAULT,40 , () => {\n \n this.startEditingValue(this.model.el.get_path(iter));\n return false;\n });\n //s.select_iter(iter);\n return true; \n });\n \n \n \n \n}\n",
- "| void updateIter" : "(Gtk.TreeIter iter, string type, string key, string kvalue) {\n\n print(\"update Iter %s, %s\\n\", key,kvalue);\n //typeof(string), // 0 key type\n //typeof(string), // 1 key\n //typeof(string), // 2 key (display)\n //typeof(string), // 3 value\n //typeof(string), // 4 value (display)\n //typeof(string), // 5 both (tooltip)\n //typeof(string), // 6 key (sort)\n \n var dl = kvalue.strip().split(\"\\n\");\n\n var dis_val = dl.length > 1 ? (dl[0].strip()+ \"...\") : dl[0];\n \n if (type == \"listener\") {\n \n \n \n this.model.el.set(iter, \n 0, type,\n 1, key,\n 2, this.keyFormat(key ,type),\n 3, kvalue,\n 4, dis_val,\n 5, \"<tt>\" + GLib.Markup.escape_text(key + \" \" +kvalue) + \"</tt>\",\n 6, \"0 \" + key\n ); \n return;\n }\n \n\n\n this.model.el.set(iter, \n 0, \"props\",\n 1, key,\n 2, this.keyFormat(key , \"prop\"),\n 3, kvalue,\n 4, dis_val,\n 5, \"<tt>\" + GLib.Markup.escape_text(key + \" \" + kvalue) + \"</tt>\",\n 6, this.keySortFormat(key)\n ); \n}",
+ "| void updateIter" : "(Gtk.TreeIter iter, string type, string key, string kvalue) {\n\n //print(\"update Iter %s, %s\\n\", key,kvalue);\n //typeof(string), // 0 key type\n //typeof(string), // 1 key\n //typeof(string), // 2 key (display)\n //typeof(string), // 3 value\n //typeof(string), // 4 value (display)\n //typeof(string), // 5 both (tooltip)\n //typeof(string), // 6 key (sort)\n \n var dl = kvalue.strip().split(\"\\n\");\n\n var dis_val = dl.length > 1 ? (dl[0].strip()+ \"...\") : dl[0];\n \n if (type == \"listener\") {\n \n \n \n this.model.el.set(iter, \n 0, type,\n 1, key,\n 2, this.keyFormat(key ,type),\n 3, kvalue,\n 4, dis_val,\n 5, \"<tt>\" + GLib.Markup.escape_text(key + \" \" +kvalue) + \"</tt>\",\n 6, \"0 \" + key\n ); \n return;\n }\n \n\n\n this.model.el.set(iter, \n 0, \"props\",\n 1, key,\n 2, this.keyFormat(key , \"prop\"),\n 3, kvalue,\n 4, dis_val,\n 5, \"<tt>\" + GLib.Markup.escape_text(key + \" \" + kvalue) + \"</tt>\",\n 6, this.keySortFormat(key)\n ); \n}",
"# JsRender.Node node" : "",
"items" : [
{
"button_press_event" : " (self, ev) => {\n _this.before_edit();\n \n \n var p = _this.AddPropertyPopup;\n p.el.set_screen(Gdk.Screen.get_default());\n p.el.show_all();\n p.el.popup(null, null, null, ev.button, ev.time);\n return true;\n}"
},
"bool hexpand" : true,
- "* pack" : "add",
"xtype" : "Button",
+ "* pack" : "add",
"$ xns" : "Gtk",
"items" : [
{
"items" : [
{
"$ Gtk.Stock stock" : "Gtk.Stock.ADD",
- "xtype" : "Image",
"* pack" : "add",
+ "xtype" : "Image",
"$ xns" : "Gtk",
"$ icon_size" : "Gtk.IconSize.MENU"
},
{
"label" : "Other",
- "* pack" : "add",
"xtype" : "Label",
+ "* pack" : "add",
"$ xns" : "Gtk"
}
]
},
{
"id" : "AddPropertyPopup",
- "* pack" : false,
"xtype" : "Menu",
+ "* pack" : false,
"$ xns" : "Gtk",
"items" : [
{
"activate" : " () => {\n _this.addProp( \"prop\", \"id\", \"\", \"\");\n}"
},
"label" : "id: _this.{ID} (Vala)",
- "* pack" : "append",
"xtype" : "MenuItem",
+ "* pack" : "append",
"tooltip_markup" : "Using _this.{ID} will map to this element",
"$ xns" : "Gtk"
},
"activate" : " ( ) => {\n\n _this.addProp( \"prop\", \"pack\",\"add\", \"*\");\n}"
},
"label" : "pack: Pack method (Vala)",
- "xtype" : "MenuItem",
"* pack" : "append",
+ "xtype" : "MenuItem",
"tooltip_markup" : "how to pack this element onto parent, (method, 2nd arg, 3rd arg) .. the 1st argument is filled by the element",
"$ xns" : "Gtk"
},
"activate" : " ( ) => {\n\n _this.addProp( \"prop\", \"ctor\",\"\", \"*\");\n}"
},
"label" : "ctor: Alterative to default contructor (Vala)",
- "* pack" : "append",
"xtype" : "MenuItem",
+ "* pack" : "append",
"tooltip_markup" : "eg. \n\nnew Clutter.Image.from_file(.....)",
"$ xns" : "Gtk"
},
"activate" : " ( ) => {\n\n _this.addProp( \"prop\", \"init\", \"{\\n\\n}\\n\", \"*\" );\n}"
},
"label" : "init: initialziation code (vala)",
- "* pack" : "append",
"xtype" : "MenuItem",
+ "* pack" : "append",
"tooltip_markup" : "This code is called after the ctor",
"$ xns" : "Gtk"
},
"activate" : " () => {\n _this.addProp( \"prop\", \"cms-id\", \"\", \"string\");\n}"
},
"label" : "cms-id: (Roo JS/Pman library)",
- "xtype" : "MenuItem",
"* pack" : "append",
+ "xtype" : "MenuItem",
"tooltip_markup" : "set the cms-id for this element, when converted to javascript, the html value will be wrapped with Pman.Cms.content({cms-id},{original-html})\n",
"$ xns" : "Gtk"
},
"activate" : " (self) => {\n\n _this.addProp( \"prop\", \"XXXX\", \"\",\"string\");\n\n}"
},
"label" : "String",
- "* pack" : "append",
"xtype" : "MenuItem",
+ "* pack" : "append",
"tooltip_markup" : "Add a user defined string property",
"$ xns" : "Gtk"
},
"activate" : " ( ) =>{\n\n _this.addProp(\"prop\", \"XXX\", \"0\", \"int\");\n}"
},
"label" : "Number",
- "* pack" : "append",
"xtype" : "MenuItem",
+ "* pack" : "append",
"tooltip_markup" : "Add a user defined number property",
"$ xns" : "Gtk"
},
"activate" : " ( ) =>{\n\n _this.addProp( \"prop\", \"XXX\", \"true\", \"bool\");\n}"
},
"label" : "Boolean",
- "* pack" : "append",
"xtype" : "MenuItem",
+ "* pack" : "append",
"tooltip_markup" : "Add a user defined boolean property",
"$ xns" : "Gtk"
},
"activate" : " ( ) =>{\n\n _this.addProp(\"prop\", \"XXXX\", \"function() { }\", \"| function\");\n}"
},
"label" : "Javascript Function",
- "* pack" : "append",
"xtype" : "MenuItem",
+ "* pack" : "append",
"tooltip_markup" : "Add a user function boolean property",
"$ xns" : "Gtk"
},
"activate" : " ( ) =>{\n\n _this.addProp( \"prop\", \"XXXX\", \"() {\\n\\n}\\n\", \"| return_type\");\n}"
},
"label" : "Vala Method",
- "xtype" : "MenuItem",
"* pack" : "append",
+ "xtype" : "MenuItem",
"tooltip_markup" : "Add a user function boolean property",
"$ xns" : "Gtk"
},
"activate" : " ( ) =>{\n\n _this.addProp( \"prop\", \"XXXX\", \"()\", \"@ void\");\n}"
},
"label" : "Vala Signal",
- "* pack" : "append",
"xtype" : "MenuItem",
+ "* pack" : "append",
"tooltip_markup" : "Add a vala signal",
"$ xns" : "Gtk"
},
"activate" : " ( ) =>{\n\n _this.addProp(\"prop\", \"flexy:if\", \"value_or_condition\", \"string\");\n}"
},
"label" : "Flexy - If",
- "* pack" : "append",
"xtype" : "MenuItem",
+ "* pack" : "append",
"tooltip_markup" : "Add a flexy if (for HTML templates)",
"$ xns" : "Gtk"
},
"activate" : " ( ) =>{\n\n _this.addProp(\"prop\", \"flexy:include\", \"name_of_file.html\", \"string\");\n}"
},
"label" : "Flexy - Include",
- "xtype" : "MenuItem",
"* pack" : "append",
+ "xtype" : "MenuItem",
"tooltip_markup" : "Add a flexy include (for HTML templates)",
"$ xns" : "Gtk"
},
"activate" : " ( ) =>{\n\n _this.addProp(\"prop\", \"flexy:foreach\", \"array,key,value\", \"string\");\n}"
},
"label" : "Flexy - Foreach",
- "xtype" : "MenuItem",
"* pack" : "append",
+ "xtype" : "MenuItem",
"tooltip_markup" : "Add a flexy foreach (for HTML templates)",
"$ xns" : "Gtk"
}
"edited" : " (path, newtext) => {\n print(\"Keyrender - signal:edited\\n\");\n \n this.el.editable = false;\n \n \n\n Gtk.TreeIter iter;\n _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path));\n GLib.Value gval;\n \n _this.model.el.get_value(iter,1, out gval);\n var oldval = (string)gval;\n \n _this.model.el.get_value(iter,0, out gval);\n var ktype = (string)gval;\n \n _this.model.el.set_value(iter, 1, newtext);\n \n if (oldval == newtext) {\n return;\n }\n \n \n print(\"ktype: %s\\n\",ktype);\n switch(ktype) {\n case \"listener\":\n var ov = _this.node.listeners.get(oldval);\n _this.node.listeners.set(newtext, ov);\n _this.node.listeners.unset(oldval);\n \n _this.updateIter(iter, ktype, newtext, ov);\n \n break;\n case \"props\":\n var ov = _this.node.props.get(oldval);\n _this.node.props.set(newtext, ov);\n _this.node.props.unset(oldval);\n _this.updateIter(iter, ktype, newtext, ov);\n break;\n }\n _this.changed();\n \n}"
},
"id" : "keyrender",
- "xtype" : "CellRendererText",
"* pack" : "pack_start,false",
+ "xtype" : "CellRendererText",
"$ xns" : "Gtk"
}
]
"edited" : " (path, newtext) => {\n print(\"Valrender - signal:edited\\n\");\n \n this.el.editable = false;\n/* \n m.set(iter, \n 0, \"listener\",\n 1, miter.get_key(),\n 2, \"<b>\" + miter.get_key() + \"</b>\",\n 3, miter.get_value(),\n 4, display_value(short);\n ); \n\n */ \n\n Gtk.TreeIter iter;\n _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path));\n GLib.Value gval;\n \n _this.model.el.get_value(iter,0, out gval);\n var ktype = (string)gval;\n \n \n _this.model.el.get_value(iter,3, out gval);\n var oldval = (string)gval;\n \n _this.model.el.get_value(iter,1, out gval);\n var key = (string)gval;\n \n \n \n switch(ktype) {\n case \"listener\":\n _this.node.listeners.set(key, newtext);\n _this.updateIter(iter,ktype,key,newtext);\n break;\n case \"props\":\n _this.node.props.set(key,newtext);\n _this.updateIter(iter,ktype, key,newtext); \n break;\n }\n// _this.load(_this.file,_this.node);\n _this.changed();\n \n}"
},
"id" : "valrender",
- "* pack" : "pack_start,true",
"xtype" : "CellRendererCombo",
+ "* pack" : "pack_start,true",
"$ editable" : false,
"$ has_entry" : true,
"$ xns" : "Gtk",
"items" : [
{
"id" : "valrendermodel",
- "* pack" : false,
"xtype" : "ListStore",
+ "* pack" : false,
"$ columns" : "typeof(string)",
"n_columns" : 1,
"$ xns" : "Gtk",
},
{
"id" : "ContextMenu",
- "xtype" : "Menu",
"* pack" : false,
+ "xtype" : "Menu",
"$ xns" : "Gtk",
"items" : [
{
"activate" : " ( ) =>{\n \n var s = _this.view.el.get_selection();\n Gtk.TreeIter iter;\n Gtk.TreeModel mod;\n s.get_selected (out mod, out iter);\n \n if (_this.view.popover == null) {\n \t\t _this.view.popover = new Xcls_PopoverProperty();\n \t\t _this.view.popover.mainwindow = _this.main_window;\n \t\t}\n \t\t\n \n _this.before_edit();\n _this.stop_editor();\n\t \n _this.keyrender.el.stop_editing(false);\n _this.keyrender.el.editable =false;\n\n _this.valrender.el.stop_editing(false);\n _this.valrender.el.editable =false;\n \n \n\tGLib.Value gvaltype, gval;\n\tmod.get_value(iter, 1 , out gval); // one is key..\n\t\n mod.get_value(iter,0, out gvaltype);\n\n\t_this.view.popover.show(_this.view.el, _this.node, (string)gvaltype, (string)gval);\n \n \n \n // _this.startEditingKey(model.get_path(iter));\n}"
},
"label" : "Edit (double click)",
- "xtype" : "MenuItem",
"* pack" : "append",
+ "xtype" : "MenuItem",
"$ xns" : "Gtk"
},
{
"activate" : " ( ) =>{\n\t_this.deleteSelected();\n}"
},
"label" : "Delete",
- "xtype" : "MenuItem",
"* pack" : "append",
+ "xtype" : "MenuItem",
"$ xns" : "Gtk"
}
]
if (oldkey == ((string)gval) && type == ((string)gvaltype)) {
- print("update iter type=%s, key=%s value=%s\n", type, key,(string) kvalue);
+ //print("update iter type=%s, key=%s value=%s\n", type, key,(string) kvalue);
this.updateIter(iter, type, key, (string)kvalue);
return true;
}
public void updateIter (Gtk.TreeIter iter, string type, string key, string kvalue) {
- print("update Iter %s, %s\n", key,kvalue);
+ //print("update Iter %s, %s\n", key,kvalue);
//typeof(string), // 0 key type
//typeof(string), // 1 key
//typeof(string), // 2 key (display)
"xtype" : "ScrolledWindow",
"@ void changed" : "()",
"$ xns" : "Gtk",
- "@ void node_selected" : "(JsRender.Node? node)",
+ "@ void node_selected" : "(JsRender.Node? node, string source)",
"# Xcls_MainWindow main_window" : "null",
"| string getActivePath" : " () {\n \n var view = this.view.el;\n if (view.get_selection().count_selected_rows() < 1) {\n return \"\";\n }\n Gtk.TreeIter iter;\n Gtk.TreeModel mod;\n view.get_selection().get_selected(out mod, out iter);\n return mod.get_path(iter).to_string();\n}\n ",
"items" : [
{
"listeners" : {
- "button_press_event" : " ( ev) => {\n //console.log(\"button press?\");\n if (! _this.before_node_change(null) ) {\n return true;\n }\n\n \n if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button != 3) {\n //print(\"click\" + ev.type);\n return false;\n }\n Gtk.TreePath res;\n if (!_this.view.el.get_path_at_pos((int)ev.x,(int)ev.y, out res, null, null, null) ) {\n return true;\n }\n \n this.el.get_selection().select_path(res);\n \n //if (!this.get('/LeftTreeMenu').el) { \n // this.get('/LeftTreeMenu').init(); \n // }\n \n _this.LeftTreeMenu.el.set_screen(Gdk.Screen.get_default());\n _this.LeftTreeMenu.el.show_all();\n _this.LeftTreeMenu.el.popup(null, null, null, 3, ev.time);\n // print(\"click:\" + res.path.to_string());\n return true;\n}",
- "cursor_changed" : " ( ) => {\n\n\n if (this.blockChanges) { // probably not needed.. \n return ;\n }\n if (!_this.before_node_change(null) ) {\n\t this.blockChanges = true;\n\t this.el.get_selection().unselect_all();\n\t this.blockChanges = false;\n\t return;\n }\n if (_this.main_window.windowstate.file == null) {\n return;\n } \n \n //var render = this.get('/LeftTree').getRenderer(); \n print(\"LEFT TREE -> view -> selection changed called\\n\");\n \n \n // -- it appears that the selection is not updated.\n \n GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {\n \n\n if (this.el.get_selection().count_selected_rows() < 1) {\n\n print(\"selected rows < 1\\n\");\n //??this.model.load( false);\n _this.node_selected(null);\n \n return false ;\n }\n \n //console.log('changed');\n var s = this.el.get_selection();\n Gtk.TreeIter iter;\n Gtk.TreeModel mod;\n s.get_selected(out mod, out iter);\n \n \n // var val = \"\";\n GLib.Value value;\n _this.model.el.get_value(iter, 2, out value);\n _this.model.activePath = mod.get_path(iter).to_string();\n \n var node = (JsRender.Node)value.dup_object();\n _this.node_selected(node);\n while (Gtk.events_pending()) {\n Gtk.main_iteration();\n }\n var cp = mod.get_path(iter);\n Gtk.TreePath sp, ep;\n this.el.get_visible_range(out sp, out ep);\n // if sp is before cp then retuns 1.\n // if cp is before ep then retuns 1.\n if (cp.compare(sp) >= 0 && ep.compare(cp) >=1) {\n return false;\n }\n \n \n \n this.el.scroll_to_cell(new Gtk.TreePath.from_string(_this.model.activePath), null, true, 0.1f,0.0f);\n \n return false;\n }); \n //_this.after_node_change(node);\n\n// _this.model.file.changed(node, \"tree\");\n \n //Seed.print( value.get_string());\n return ;\n \n}",
+ "button_press_event" : " ( ev) => {\n //console.log(\"button press?\");\n this.lastEventSource = \"tree\";\n if (! _this.before_node_change(null) ) {\n \n return true;\n }\n\n \n if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button != 3) {\n //print(\"click\" + ev.type);\n return false;\n }\n Gtk.TreePath res;\n if (!_this.view.el.get_path_at_pos((int)ev.x,(int)ev.y, out res, null, null, null) ) {\n return true;\n }\n \n this.el.get_selection().select_path(res);\n \n //if (!this.get('/LeftTreeMenu').el) { \n // this.get('/LeftTreeMenu').init(); \n // }\n \n _this.LeftTreeMenu.el.set_screen(Gdk.Screen.get_default());\n _this.LeftTreeMenu.el.show_all();\n _this.LeftTreeMenu.el.popup(null, null, null, 3, ev.time);\n // print(\"click:\" + res.path.to_string());\n return true;\n}",
+ "cursor_changed" : " ( ) => {\n\n\n if (this.blockChanges) { // probably not needed.. \n return ;\n }\n if (!_this.before_node_change(null) ) {\n\t this.blockChanges = true;\n\t this.el.get_selection().unselect_all();\n\t this.blockChanges = false;\n\t return;\n }\n if (_this.main_window.windowstate.file == null) {\n return;\n } \n \n //var render = this.get('/LeftTree').getRenderer(); \n print(\"LEFT TREE -> view -> selection changed called\\n\");\n \n \n // -- it appears that the selection is not updated.\n \n GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {\n \n\n if (this.el.get_selection().count_selected_rows() < 1) {\n\n print(\"selected rows < 1\\n\");\n //??this.model.load( false);\n _this.node_selected(null, this.lastEventSource);\n \n return false ;\n }\n \n //console.log('changed');\n var s = this.el.get_selection();\n Gtk.TreeIter iter;\n Gtk.TreeModel mod;\n s.get_selected(out mod, out iter);\n \n \n // var val = \"\";\n GLib.Value value;\n _this.model.el.get_value(iter, 2, out value);\n _this.model.activePath = mod.get_path(iter).to_string();\n \n var node = (JsRender.Node)value.dup_object();\n _this.node_selected(node, this.lastEventSource);\n while (Gtk.events_pending()) {\n Gtk.main_iteration();\n }\n var cp = mod.get_path(iter);\n Gtk.TreePath sp, ep;\n this.el.get_visible_range(out sp, out ep);\n // if sp is before cp then retuns 1.\n // if cp is before ep then retuns 1.\n if (cp.compare(sp) >= 0 && ep.compare(cp) >=1) {\n return false;\n }\n \n \n \n this.el.scroll_to_cell(new Gtk.TreePath.from_string(_this.model.activePath), null, true, 0.1f,0.0f);\n \n return false;\n }); \n //_this.after_node_change(node);\n\n// _this.model.file.changed(node, \"tree\");\n \n //Seed.print( value.get_string());\n return ;\n \n}",
"drag_begin" : "( ctx) => {\n\t//print('SOURCE: drag-begin');\n \n \n //this.targetData = \"\";\n \n // find what is selected in our tree...\n \n var s = _this.view.el.get_selection();\n if (s.count_selected_rows() < 1) {\n return;\n }\n Gtk.TreeIter iter;\n Gtk.TreeModel mod;\n s.get_selected(out mod, out iter);\n\n \n\n // set some properties of the tree for use by the dropped element.\n GLib.Value value;\n _this.model.el.get_value(iter, 2, out value);\n var tp = mod.get_path(iter).to_string();\n var data = (JsRender.Node)(value.dup_object());\n var xname = data.fqn();\n print (\"XNAME IS \" + xname+ \"\\n\");\n this.dragData = tp;\n this.dropList = _this.main_window.windowstate.file.palete().getDropList(xname);\n \n print (\"DROP LIST IS \" + string.joinv(\", \", this.dropList) + \"\\n\");\n \n\n // make the drag icon a picture of the node that was selected\n \n \n // by default returns the path..\n var path = _this.model.el.get_path(iter);\n\n \n var pix = this.el.create_row_drag_icon ( path);\n \n Gtk.drag_set_icon_surface (ctx, pix) ;\n \n return;\n}",
"drag_end" : " (drag_context) => {\n\t//Seed.print('LEFT-TREE: drag-end');\n this.dragData = \"\";\n this.dropList = null;\n// this.targetData = \"\";\n this.highlightDropPath(\"\",0);\n// return true;\n}",
"drag_motion" : " ( ctx, x, y, time) => {\n print(\"got drag motion\\n\");\n var src = Gtk.drag_get_source_widget(ctx);\n this.drag_x = x;\n this.drag_y = y; \n\n if (src != this.el) {\n \n \n \n // the point of this is to detect where an item could be dropped..\n print(\"requesting drag data\\n\");\n this.drag_in_motion = true;\n \n // request data that will be recieved by the recieve... \n Gtk.drag_get_data\n (\n this.el, // will receive 'drag-data-received' signal \n ctx, // represents the current state of the DnD \n Gdk.Atom.intern(\"STRING\",true), // the target type we want \n time // time stamp \n );\n return true;\n } \n\n\n print(\"action: %d\\n\", ctx.get_actions());\n //print(\"GETTING POS\");\n var targetData = \"\";\n\n Gtk.TreePath path;\n Gtk.TreeViewDropPosition pos;\n var isOver = _this.view.el.get_dest_row_at_pos(this.drag_x,this.drag_y, out path, out pos);\n\n // if there are not items in the tree.. the we have to set isOver to true for anything..\n var isEmpty = false;\n if (_this.model.el.iter_n_children(null) < 1) {\n print(\"got NO children?\\n\");\n isOver = true; //??? \n isEmpty = true;\n pos = Gtk.TreeViewDropPosition.INTO_OR_AFTER;\n }\n\n\n // ------------- a drag from self..\n\n\n //var action = Gdk.DragAction.COPY;\n // unless we are copying!!! ctl button..\n \n var action = (ctx.get_actions() & Gdk.DragAction.MOVE) > 0 ?\n Gdk.DragAction.COPY : Gdk.DragAction.MOVE ;\n // Gdk.DragAction.MOVE : Gdk.DragAction.COPY ;\n\n\n if (_this.model.el.iter_n_children(null) < 1) {\n // no children.. -- asume it's ok..\n \n targetData = \"|%d|\".printf((int)Gtk.TreeViewDropPosition.INTO_OR_AFTER);\n \n this.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0); \n Gdk.drag_status(ctx, action ,time);\n return true;\n \n // continue through to allow drop...\n\n } \n \n \n\n \n \n //print(\"ISOVER? \" + isOver);\n if (!isOver) {\n \n Gdk.drag_status(ctx, 0 ,time);\n this.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0); \n return false;\n\n }\n \n // drag node is parent of child..\n //console.log(\"SRC TREEPATH: \" + src.treepath);\n //console.log(\"TARGET TREEPATH: \" + data.path.to_string());\n \n // nned to check a few here..\n //Gtk.TreeViewDropPosition.INTO_OR_AFTER\n //Gtk.TreeViewDropPosition.INTO_OR_BEFORE\n //Gtk.TreeViewDropPosition.AFTER\n //Gtk.TreeViewDropPosition.BEFORE\n \n // locally dragged items to not really use the \n var selection_text = this.dragData;\n \n \n \n if (selection_text == null || selection_text.length < 1) {\n //print(\"Error - drag selection text returned NULL\");\n Gdk.drag_status(ctx, 0 ,time);\n this.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0);\n return false;\n }\n \n \n // see if we are dragging into ourself?\n var target_path = path.to_string(); \n print (\"Drag %s onto %s--%d\\n \", selection_text, target_path, pos);\n \n // pos : 3 = ontop - 0 = after, 1 = before\n //print(\"target_path=\"+target_path);\n\n // \n if (selection_text == target_path) {\n print(\"self drag ?? == we should perhaps allow copy onto self..\\n\");\n \n Gdk.drag_status(ctx, 0 ,time);\n this.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0);\n return false;\n// -- fixme -- this is not really correct..\n\n }\n \n // check that \n //print(\"DUMPING DATA\");\n //console.dump(data);\n // path, pos\n \n //print(data.path.to_string() +' => '+ data.pos);\n \n // dropList is a list of xtypes that this node could be dropped on.\n // it is set up when we start to drag..\n \n \n targetData = _this.model.findDropNodeByPath( path.to_string(), this.dropList, pos);\n \n print(\"targetDAta: \" + targetData +\"\\n\");\n \n if (targetData.length < 1) {\n //print(\"Can not find drop node path\");\n \n Gdk.drag_status(ctx, 0, time);\n this.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0);\n return false;\n }\n \n var td_ar = targetData.split(\"|\");\n \n \n\n Gdk.drag_status(ctx, action ,time);\n this.highlightDropPath(td_ar[0], (Gtk.TreeViewDropPosition)int.parse(td_ar[1]));\n return true;\n \n \n}",
"$ enable_tree_lines" : true,
"$ headers_visible" : false,
"| void highlightDropPath" : " ( string treepath, Gtk.TreeViewDropPosition pos) {\n\n // highlighting for drag/drop\n if (treepath.length > 0) {\n this.el.set_drag_dest_row( new Gtk.TreePath.from_string( treepath ), pos);\n } else {\n this.el.set_drag_dest_row(null, Gtk.TreeViewDropPosition.INTO_OR_AFTER);\n }\n \n}",
+ "$ string lastEventSource" : "\"\"",
"# bool drag_in_motion" : "",
"# bool blockChanges" : false,
"$ xns" : "Gtk",
- "| void selectNode" : "(string treepath_str) {\n //this.selection.select_path(new Gtk.TreePath.from_string( treepath_str));\n var tp = new Gtk.TreePath.from_string(treepath_str);\n \n this.el.set_cursor(tp, null, false); \n this.el.scroll_to_cell(tp, null, false, 0,0);\n}\n",
+ "| void setCursor" : "(string treepath, string sourceEvent) => {\n\tthis.lastEventSource = sourceEvent;\n this.el.set_cursor(new Gtk.TreePath.from_string(treepath), null, false); \n \n}\n",
+ "| void selectNode" : "(string treepath_str, string source) {\n\tthis.lastEventSource = source;\n //this.selection.select_path(new Gtk.TreePath.from_string( treepath_str));\n var tp = new Gtk.TreePath.from_string(treepath_str);\n \n this.el.set_cursor(tp, null, false); \n this.el.scroll_to_cell(tp, null, false, 0,0);\n}\n",
"items" : [
{
"| string findDropNode" : " (string treepath_str, string[] targets) {\n\n // this is used by the dragdrop code in the roo version AFAIR..\n\n //var path = treepath_str.replace(/^builder-/, '');\n // treemap is depreciated... - should really check if model has any entries..\n\n if (this.el.iter_n_children(null) < 1) {\n //print(\"NO KEYS\");\n return \"|%d\".printf((int)Gtk.TreeViewDropPosition.INTO_OR_AFTER);\n }\n //print(\"FIND treepath: \" + path);\n //console.dump(this.treemap);\n \n //if (!treepath_str.match(/^builder-/)) {\n // return []; // nothing!\n //}\n if (targets.length > 0 && targets[0] == \"*\") {\n return treepath_str;\n }\n return this.findDropNodeByPath(treepath_str,targets, -1);\n}\n",
},
{
"listeners" : {
- "activate" : " () => {\n var node = _this.getActiveElement();\n var name = DialogSaveModule.singleton().show(\n (Gtk.Window) _this.el.get_toplevel (), \n _this.main_window.windowstate.project, \n node\n );\n if (name.length < 1) {\n return;\n \n }\n node.props.set(\"* xinclude\", name);\n node.items.clear();\n\n\n var s = _this.view.el.get_selection();\n \n print(\"GET SELECTED?\");\n Gtk.TreeIter iter;\n Gtk.TreeModel mod;\n\n \n if (!s.get_selected(out mod, out iter)) {\n return; // nothing seleted..\n }\n Gtk.TreeIter citer;\n var n_cn = mod.iter_n_children(iter) -1;\n for (var i = n_cn; i > -1; i--) {\n mod.iter_nth_child(out citer, iter, i);\n \n\n print(\"removing node from Tree\\n\"); \n \n _this.model.el.remove(ref citer);\n }\n _this.changed();\n _this.node_selected(node);\n \n \n}"
+ "activate" : " () => {\n var node = _this.getActiveElement();\n var name = DialogSaveModule.singleton().show(\n (Gtk.Window) _this.el.get_toplevel (), \n _this.main_window.windowstate.project, \n node\n );\n if (name.length < 1) {\n return;\n \n }\n node.props.set(\"* xinclude\", name);\n node.items.clear();\n\n\n var s = _this.view.el.get_selection();\n \n print(\"GET SELECTED?\");\n Gtk.TreeIter iter;\n Gtk.TreeModel mod;\n\n \n if (!s.get_selected(out mod, out iter)) {\n return; // nothing seleted..\n }\n Gtk.TreeIter citer;\n var n_cn = mod.iter_n_children(iter) -1;\n for (var i = n_cn; i > -1; i--) {\n mod.iter_nth_child(out citer, iter, i);\n \n\n print(\"removing node from Tree\\n\"); \n \n _this.model.el.remove(ref citer);\n }\n _this.changed();\n _this.node_selected(node, \"tree\");\n \n \n}"
},
"label" : "Save as Module",
"* pack" : "add",
// my vars (def)
public signal bool before_node_change (JsRender.Node? node);
public signal void changed ();
- public signal void node_selected (JsRender.Node? node);
+ public signal void node_selected (JsRender.Node? node, string source);
public Xcls_MainWindow main_window;
// ctor
public string[] dropList;
public int drag_x;
public int drag_y;
+ public string lastEventSource;
public bool drag_in_motion;
public bool blockChanges;
this.el = new Gtk.TreeView();
// my vars (dec)
+ this.lastEventSource = "";
this.blockChanges = false;
// set gobject values
//listeners
this.el.button_press_event.connect( ( ev) => {
//console.log("button press?");
+ this.lastEventSource = "tree";
if (! _this.before_node_change(null) ) {
+
return true;
}
print("selected rows < 1\n");
//??this.model.load( false);
- _this.node_selected(null);
+ _this.node_selected(null, this.lastEventSource);
return false ;
}
_this.model.activePath = mod.get_path(iter).to_string();
var node = (JsRender.Node)value.dup_object();
- _this.node_selected(node);
+ _this.node_selected(node, this.lastEventSource);
while (Gtk.events_pending()) {
Gtk.main_iteration();
}
}
}
- public void selectNode (string treepath_str) {
+ public void setCursor (string treepath, string sourceEvent) => {
+ this.lastEventSource = sourceEvent;
+ this.el.set_cursor(new Gtk.TreePath.from_string(treepath), null, false);
+
+ }
+ public void selectNode (string treepath_str, string source) {
+ this.lastEventSource = source;
//this.selection.select_path(new Gtk.TreePath.from_string( treepath_str));
var tp = new Gtk.TreePath.from_string(treepath_str);
_this.model.el.remove(ref citer);
}
_this.changed();
- _this.node_selected(node);
+ _this.node_selected(node, "tree");
});
"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",
"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"
},
{
"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",
},
{
"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"
"$ xns" : "Gtk",
"items" : [
{
+ "listeners" : {
+ "button_release_event" : "() => {\n\tthis.onCursorChanged();\n\n\treturn false;\n}"
+ },
"gboolean show_line_marks" : true,
"id" : "sourceview",
- "* 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((ps) => {\n if (this.loading) {\n return;\n }\n if (ps.name != \"cursor-position\") {\n return;\n }\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 \n var node = _this.file.lineToNode(ln);\n \n if (node == null) {\n print(\"can not find node\\n\");\n return;\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; \n\t print(\"changing cursor on tree..\\n\");\n ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false);\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 });\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) {\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 (this.allow_node_scroll) {\n\t\t \n \tthis.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);\n\t}\n \n \n \n for (var i = 0; i < buf.get_line_count();i++) {\n if (i < (sel.line_start -1) || i > (sel.line_end -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",
+ "| 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\t \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, nstart, nend);\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,
"| string toString" : "() {\n Gtk.TextIter s;\n Gtk.TextIter e;\n this.el.get_buffer().get_start_iter(out s);\n this.el.get_buffer().get_end_iter(out e);\n var ret = this.el.get_buffer().get_text(s,e,true);\n //print(\"TO STRING? \" + ret);\n return ret;\n}\n",
- "| void loadFile" : "( ) {\n this.loading = true;\n var buf = this.el.get_buffer();\n buf.set_text(\"\",0);\n var sbuf = (Gtk.SourceBuffer) buf;\n\n \n\n if (_this.file == null || _this.file.xtype != \"Roo\") {\n print(\"xtype != Roo\");\n this.loading = false;\n return;\n }\n \n // get the string from the rendered tree...\n \n var str = _this.file.toSource();\n \n// print(\"setting str %d\\n\", str.length);\n buf.set_text(str, str.length);\n var lm = Gtk.SourceLanguageManager.get_default();\n \n //?? is javascript going to work as js?\n \n ((Gtk.SourceBuffer)(buf)) .set_language(lm.get_language(_this.file.language));\n \n \n Gtk.TextIter start;\n Gtk.TextIter end; \n \n sbuf.get_bounds (out start, out end);\n sbuf.remove_source_marks (start, end, null); // remove all marks..\n \n \n \n \n this.loading = false; \n}\n",
+ "| void loadFile" : "( ) {\n this.loading = true;\n \n \n // get the cursor and scroll position....\n var buf = this.el.get_buffer();\n\tvar cpos = buf.cursor_position;\n \n print(\"BEFORE LOAD cursor = %d\\n\", cpos);\n \n var vadj = this.el.get_vadjustment();\n \n \n \n buf.set_text(\"\",0);\n var sbuf = (Gtk.SourceBuffer) buf;\n\n \n\n if (_this.file == null || _this.file.xtype != \"Roo\") {\n print(\"xtype != Roo\");\n this.loading = false;\n return;\n }\n \n // get the string from the rendered tree...\n \n var str = _this.file.toSource();\n \n// print(\"setting str %d\\n\", str.length);\n buf.set_text(str, str.length);\n var lm = Gtk.SourceLanguageManager.get_default();\n \n //?? is javascript going to work as js?\n \n ((Gtk.SourceBuffer)(buf)) .set_language(lm.get_language(_this.file.language));\n \n \n Gtk.TextIter start;\n Gtk.TextIter end; \n \n sbuf.get_bounds (out start, out end);\n sbuf.remove_source_marks (start, end, null); // remove all marks..\n \n GLib.Timeout.add(500, () => {\n \n print(\"RESORTING cursor to = %d\\n\", cpos);\n\t\tGtk.TextIter cpos_iter;\n\t\tbuf.get_iter_at_offset(out cpos_iter, cpos);\n\t\tbuf.place_cursor(cpos_iter); \n\t\t\n\t\tthis.el.set_vadjustment(vadj);\n\t\tthis.onCursorChanged();\n\t\treturn false;\n\t});\n\t\t\n this.loading = false; \n}\n",
"* pack" : "add",
"xtype" : "SourceView",
"bool allow_node_scroll" : true,
"| void highlightErrorsJson" : " (string type, Json.Object obj) {\n Gtk.TextIter start;\n Gtk.TextIter end; \n \n var buf = this.el.get_buffer();\n var sbuf = (Gtk.SourceBuffer)buf;\n buf.get_bounds (out start, out end);\n \n sbuf.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 ;\n }\n var err = obj.get_object_member(type);\n \n if (_this.file == null) { \n return; // just in case the file has not loaded yet?\n }\n \n\n var valafn = \"\";\n try { \n var regex = new Regex(\"\\\\.bjs$\");\n \n \n valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , \".vala\");\n } catch (GLib.RegexError e) {\n return;\n } \n\n if (!err.has_member(valafn)) {\n print(\"File path has no errors\\n\");\n return ;\n }\n var lines = err.get_object_member(valafn);\n \n \n \n var tlines = buf.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) -1 ;\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 sbuf.get_iter_at_line( out iter, eline);\n //print(\"mark line\\n\");\n var msg = type + \" on line: %d - %s\".printf(eline+1, valafn);\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 sbuf.create_source_mark(msg, type, iter);\n } );\n return ;\n \n \n\n\n}",
"$ xns" : "Gtk",
"gboolean show_line_numbers" : true,
+ "$ string propSelected" : "\"\"",
"gboolean editable" : false
}
]
// my vars (def)
public bool loading;
public bool allow_node_scroll;
+ public string propSelected;
// ctor
public Xcls_sourceview(Xcls_WindowRooView _owner )
// my vars (dec)
this.loading = true;
this.allow_node_scroll = true;
+ this.propSelected = "";
// set gobject values
this.el.editable = false;
this.el.override_font(description);
this.loading = true;
- var buf = this.el.get_buffer();
- buf.notify.connect((ps) => {
- if (this.loading) {
- return;
- }
- if (ps.name != "cursor-position") {
- return;
- }
- print("cursor changed : %d\n", buf.cursor_position);
- Gtk.TextIter cpos;
- buf.get_iter_at_offset(out cpos, buf.cursor_position);
-
- var ln = cpos.get_line();
-
- var node = _this.file.lineToNode(ln);
-
- if (node == null) {
- print("can not find node\n");
- return;
- }
- var ltree = _this.main_window.windowstate.left_tree;
- var tp = ltree.model.treePathFromNode(node);
- print("got tree path %s\n", tp);
- if (tp != "") {
- this.allow_node_scroll = false;
- print("changing cursor on tree..\n");
- ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false);
- // scrolling is disabled... as node selection calls scroll 10ms after it changes.
- GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => {
- this.allow_node_scroll = true;
- return false;
- });
- }
-
- // highlight the node..
-
- });
+ //var buf = this.el.get_buffer();
+ //buf.notify.connect(this.onCursorChanged);
}
+
+ //listeners
+ this.el.button_release_event.connect( () => {
+ this.onCursorChanged();
+
+ return false;
+ });
}
// user defined functions
- public void nodeSelected (JsRender.Node? sel) {
+ public void onCursorChanged (/*ParamSpec ps*/) {
+ if (this.loading) {
+ return;
+ }
+ // if (ps.name != "cursor-position") {
+ // return;
+ // }
+
+ var buf = this.el.get_buffer();
+ print("cursor changed : %d\n", buf.cursor_position);
+ Gtk.TextIter cpos;
+ buf.get_iter_at_offset(out cpos, buf.cursor_position);
+
+ var ln = cpos.get_line();
+ print("cursor changed line : %d\n", ln);
+ var node = _this.file.lineToNode(ln+1);
+
+ if (node == null) {
+ print("can not find node\n");
+ return;
+ }
+ var prop = node.lineToProp(ln+1);
+ print("prop : %s", prop == null ? "???" : prop);
+
+
+
+
+
+
+ var ltree = _this.main_window.windowstate.left_tree;
+ var tp = ltree.model.treePathFromNode(node);
+ print("got tree path %s\n", tp);
+ if (tp != "") {
+ this.allow_node_scroll = false; /// block node scrolling..
+
+
+ //print("changing cursor on tree..\n");
+
+
+
+ // let's try allowing editing on the methods.
+ // a little klunky at present..
+ this.propSelected = "";
+ if (prop != null) {
+ //see if we can find it..
+ var kv = prop.split(":");
+ if (kv[0] == "p") {
+
+ //var k = prop.get_key(kv[1]);
+ // fixme -- need to determine if it's an editable property...
+ this.propSelected = prop;
+
+ } else if (kv[0] == "l") {
+ this.propSelected = prop;
+
+ }
+ }
+ ltree.view.setCursor(tp, "editor");
+ // ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false);
+ this.nodeSelected(node,false);
+
+ // scrolling is disabled... as node selection calls scroll 10ms after it changes.
+ GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => {
+ this.allow_node_scroll = true;
+ return false;
+ });
+ }
+
+ // highlight the node..
+ }
+ public void nodeSelected (JsRender.Node? sel, bool scroll ) {
// clear all the marks..
- Gtk.TextIter start;
+ Gtk.TextIter start;
Gtk.TextIter end;
sbuf.get_bounds (out start, out end);
//if (cur_line > sel.line_start && cur_line < sel.line_end) {
//} else {
- if (this.allow_node_scroll) {
+ if (scroll) {
this.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);
}
+ var start_line = sel.line_start;
+ var end_line = sel.line_end;
+
+
+ this.el.editable = false;
+ // now if we have selected a property...
+ if (this.propSelected.length> 0 ) {
+
+ int nstart, nend;
+ if (sel.getPropertyRange(this.propSelected, out nstart, out nend) && nend > nstart) {
+ start_line = nstart;
+ end_line = nend;
+ this.el.editable = true;
+ }
+ print("propSelected = %s range %d -> %d\n", this.propSelected, nstart, nend);
+
+
+ }
+
+ // check selection - if it's out of 'bounds'
+ if (this.el.editable && sbuf.get_has_selection()) {
+ Gtk.TextIter sel_start_iter, sel_end_iter;
+ sbuf.get_selection_bounds(out sel_start_iter, out sel_end_iter);
+
+ if (sel_start_iter.get_line() < start_line || sel_end_iter.get_line() > end_line ||
+ sel_start_iter.get_line() > end_line || sel_end_iter.get_line() < start_line ) {
+ // save?
+ this.el.editable = false;
+ }
+
+ }
+
+
for (var i = 0; i < buf.get_line_count();i++) {
- if (i < (sel.line_start -1) || i > (sel.line_end -1)) {
+ if (i < (start_line -1) || i > (end_line -1)) {
sbuf.get_iter_at_line(out iter, i);
sbuf.create_source_mark(null, "grey", iter);
}
public void loadFile ( ) {
this.loading = true;
+
+
+ // get the cursor and scroll position....
var buf = this.el.get_buffer();
+ var cpos = buf.cursor_position;
+
+ print("BEFORE LOAD cursor = %d\n", cpos);
+
+ var vadj = this.el.get_vadjustment();
+
+
+
buf.set_text("",0);
var sbuf = (Gtk.SourceBuffer) buf;
sbuf.get_bounds (out start, out end);
sbuf.remove_source_marks (start, end, null); // remove all marks..
-
-
-
+ GLib.Timeout.add(500, () => {
+
+ print("RESORTING cursor to = %d\n", cpos);
+ Gtk.TextIter cpos_iter;
+ buf.get_iter_at_offset(out cpos_iter, cpos);
+ buf.place_cursor(cpos_iter);
+
+ this.el.set_vadjustment(vadj);
+ this.onCursorChanged();
+ return false;
+ });
+
this.loading = false;
}
public void highlightErrorsJson (string type, Json.Object obj) {
this.template_select = new DialogTemplateSelect();
this.children_loaded = true;
- this.left_tree.node_selected.connect((sel) => {
- if (this.file.xtype == "Roo") {
- this.window_rooview.sourceview.nodeSelected(sel);
- } else {
- this.window_gladeview.sourceview.nodeSelected(sel);
- }
- });
+
this.valasource = new Palete.ValaSource();
this.valasource.compiled.connect(this.valaCompiled);
return this.leftTreeBeforeChange();
});
-
+
+ this.left_tree.node_selected.connect((sel, source) => {
+ if (source == "editor") {
+ return;
+ }
+ if (this.file.xtype == "Roo") {
+ this.window_rooview.sourceview.nodeSelected(sel,false);
+ } else {
+ this.window_gladeview.sourceview.nodeSelected(sel);
+ }
+ });
+
this.left_tree.node_selected.connect((sel) => {
this.leftTreeNodeSelected(sel);
});
{
"name" : "builder",
"compile_flags" : "",
+ "execute_args" : "",
"target_bin" : "/tmp/builder",
"sources" : [
"../Builder4/About.vala",
{
"name" : "_default_",
"compile_flags" : "--thread -X -lm --target-glib=2.32 -g",
+ "execute_args" : "",
"target_bin" : "",
"sources" : [
"../../../app.Builder.js",
"../Palete",
"../Project",
"../vapi",
- "../c"
+ "../c",
+ "../..//tests"
],
"packages" : [
"gdk-3.0",
"gee-1.0",
"posix",
"libvala-0.24",
- "libvala-0.30"
+ "libvala-0.30",
+ "librsvg-2.0",
+ "libvala-0.32"
]
}
]
\ No newline at end of file
}
public override void setSource(string str) {}
- public override string toSource() // no seed support currently.
+ public override string toSourceCode() // no seed support currently.
{
+ return NodeToVala.mungeFile(this);
+ }
+ // this is only used by dumping code...
+ public override string toSource() // no seed support currently.
+ {
+
+
/*
if (this.tree == null) {
return "";
this.content_type = "";
this.build_module = "";
this.loaded = false;
- print("JsRender.cto() - reset transStrings\n");
+ //print("JsRender.cto() - reset transStrings\n");
this.transStrings = new Gee.HashMap<string,string> ();
// should use basename reallly...
public abstract void save();
public abstract void saveHTML(string html);
public abstract string toSource() ;
+ public abstract string toSourceCode() ; // used by commandline tester..
public abstract void setSource(string str);
public abstract string toSourcePreview() ;
public abstract void removeFiles() ;
}
public void setNodeLine(int line, Node node) {
- print("Add node @ %d\n", line);
+ //print("Add node @ %d\n", line);
+ if (this.node_lines_map.has_key(line)) {
+ return;
+ }
this.node_lines.add(line);
this.node_lines_map.set(line, node);
+
}
public void setLine(int line, string type, string prop) {
- this.lines.add(line);
+ if (this.line_map.has_key(line)) {
+ if (this.line_map.get(line) != "e:" ) {
+ return;
+ }
+ } else {
+ this.lines.add(line);
+ }
this.line_map.set(line, type + ":" + prop);
+ GLib.debug("setLine %d, %s", line, type + ":" + prop);
}
public void sortLines() {
- print("sortLines\n");
+ //print("sortLines\n");
this.lines.sort((a,b) => {
- return (int)b-(int)a;
+ return (int)a-(int)b;
});
this.node_lines.sort((a,b) => {
return (int)a-(int)b;
}
public Node? lineToNode(int line)
{
- print("Searching for line %d\n",line);
+ //print("Searching for line %d\n",line);
var l = -1;
- foreach(int el in this.node_lines) {
- print("all lines %d\n", el);
- }
+ //foreach(int el in this.node_lines) {
+ //print("all lines %d\n", el);
+ //}
foreach(int el in this.node_lines) {
- print("?match %d\n", el);
+ //print("?match %d\n", el);
if (el < line) {
l = el;
- print("LESS\n");
+ //print("LESS\n");
continue;
}
if (el == line) {
- print("SAME\n");
+ //print("SAME\n");
l = el;
break;
}
if (l > -1) {
- print("RETURNING NODE ON LINE %d", l);
- return this.node_lines_map.get(l);
+ var ret = this.node_lines_map.get(l);
+ if (line > ret.line_end) {
+ return null;
+ }
+ //print("RETURNING NODE ON LINE %d", l);
+ return ret;
}
return null;
}
if (l > -1) {
- print("RETURNING NODE ON LINE %d", l);
- return this.node_lines_map.get(l);
+ var ret = this.node_lines_map.get(l);
+ if (line > ret.line_end) {
+ return null;
+ }
+ //print("RETURNING NODE ON LINE %d", l);
+ return ret;
+
}
return null;
}
+ public string lineToProp(int line)
+ {
+ // assume lineToNode called first...
+ var l = -1;
+ //foreach(int el in this.lines) {
+ // //print("all lines %d\n", el);
+ //
+
+
+ foreach(int el in this.lines) {
+ //print("?match %d\n", el);
+ if (el < line) {
+
+ l = el;
+ //print("LESS\n");
+ continue;
+ }
+ if (el == line) {
+ //print("SAME\n");
+ l = el;
+ break;
+ }
+ if (l > -1) {
+ //print("RETURNING NODE ON LINE %d", l);
+ return this.line_map.get(l);
+ }
+ return null;
+
+ }
+ if (l > -1) {
+ //print("RETURNING NODE ON LINE %d", l);
+ return this.line_map.get(l);
+ }
+ return null;
+
+ }
+
+ public bool getPropertyRange(string prop, out int start, out int end)
+ {
+ start = -1;
+ foreach(int el in this.lines) {
+ if (start < 0) {
+ if (this.line_map.get(el) == prop) {
+ start = el;
+ end = el;
+ }
+ continue;
+ }
+ end = el -1;
+ break;
+ }
+ return start > -1;
+
+
+ }
+
+ public void dumpProps(string indent = "")
+ {
+ print("%s:\n" , this.fqn());
+ foreach(int el in this.lines) {
+ print("%d: %s%s\n", el, indent, this.line_map.get(el));
+ }
+ foreach(Node n in this.items) {
+ n.dumpProps(indent + " ");
+ }
+ }
+
+
public string uid()
{
this.props.set("xtype", ar[ar.length-1]);
var l = name.length - (ar[ar.length-1].length +1);
this.props.set("$ xns", name.substring(0, l));
- print("setFQN %s to %s\n", name , this.fqn());
+ //print("setFQN %s to %s\n", name , this.fqn());
}
kk+= kkv[i];
}
}
- print("normalize %s => %s\n", key,string.joinv("=:=",kk));
+ //print("normalize %s => %s\n", key,string.joinv("=:=",kk));
switch(kk.length) {
case 1:
*
* usage : x = (new JsRender.NodeToJs(node)).munge();
*
+ *
+ * We are changing this to output as we go.
+ * However... since line-endings on properties have ',' (not ;) like vala.
+ * we have to be a bit smarter about how to output.
+ *
+ *
+ *
*/
//this.ar_props = new Gee.HashMap<string,string>();
+
+ // this is the bit that causes issues - we have to output as we go, otherwise we
+ // can not work out which line is which...
+
this.out_props = new Gee.HashMap<string,string>();
this.out_listeners = new Gee.HashMap<string,string>();
+
+
this.out_nodeprops = new Gee.HashMap<string,Node>() ;
this.out_children = new Gee.ArrayList<Node> ();
- this.out_props_array = new Gee.HashMap<string,Gee.ArrayList<Node>>() ;
+
+ this.out_props_array = new Gee.HashMap<string,Gee.ArrayList<Node>>(); // filled in by 'checkChildren'
this.out_props_array_plain = new Gee.HashMap<string,Gee.ArrayList<string>>() ;
var spad = this.pad.substring(0, this.pad.length-indent);
if (this.node.props.has_key("* xinclude")) {
- this.addLine("Roo.apply(" + this.node.props.get("* xinclude") + "._tree(), {");
+ this.addLine("Roo.apply(" + this.node.props.get("* xinclude") + "._tree(), {",0 );
} else {
- this.addLine("{");
+ this.addLine("{", 0);
}
var suffix = "";
// output the items...
// work out remaining items...
- var total_nodes = this.out_props.size +
- this.out_props_array_plain.size +
- (this.out_listeners.size > 0 ? 1 : 0) +
- this.out_nodeprops.size +
- this.out_props_array.size +
- (this.out_children.size > 0 ? 1 : 0);
-
-
+
+ // output xns / xtype first..
+ if (this.out_props.has_key("xtype")) {
+ var v = this.out_props.get("xtype");
+ this.node.setLine(this.cur_line, "p","xtype");
+ this.addLine(this.pad + "xtype" + " : " + v + suffix, ',');
+ }
// plain properties.
var iter = this.orderedPropKeys().list_iterator();
while(iter.next()) {
- total_nodes--;
- suffix = total_nodes > 0 ? "," : "";
+
+
var k = iter.get();
+ if (k == "xns" || k == "xtype") {
+ continue;
+ }
+
var v = this.out_props.get(k);
+ this.node.setLine(this.cur_line, "p",k);
+ this.addLine(this.pad + k + " : " + v + suffix, ',');
+
+ this.node.setLine(this.cur_line, "e", "");
- this.addMultiLine(this.pad + k + " : " + v + suffix);
}
// listeners..
if (this.out_listeners.size > 0 ) {
- total_nodes--;
- this.addLine(this.pad + "listeners : {");
+
+ this.addLine(this.pad + "listeners : {", 0);
iter = this.orderedListenerKeys().list_iterator();
- var sz = this.out_listeners.size;
while(iter.next()) {
- sz--;
- suffix = sz > 0 ? "," : "";
+
var k = iter.get();
var v = this.out_listeners.get(k);
- this.addMultiLine(this.pad + indent_str + k + " : " + v + suffix);
+ this.node.setLine(this.cur_line, "l",k); //listener
+ this.addLine(this.pad + indent_str + k + " : " + v , ',');
+ this.node.setLine(this.cur_line, "e", "");
}
- suffix = total_nodes > 0 ? "," : "";
- this.addLine(this.pad + "}" + suffix);
+
+ this.closeLine();
+ this.addLine(this.pad + "}" ,',');
}
//------- at this point it is the end of the code relating directly to the object..
- this.node.line_end = this.cur_line;
-
+ if (this.out_props.has_key("xns")) {
+ var v = this.out_props.get("xns");
+ this.node.setLine(this.cur_line, "p","xns");
+ this.addLine(this.pad + "xns" + " : " + v + suffix, ',');
+ this.node.setLine(this.cur_line, "p","| xns");
+ this.addLine(this.pad + "'|xns' : '" + v + "'", ',');
+ this.node.setLine(this.cur_line, "e", "");
+ }
+ this.node.line_end = this.cur_line;
// * prop
var niter = this.out_nodeprops.map_iterator();
while(niter.next()) {
- total_nodes--;
- suffix = total_nodes > 0 ? "," : "";
- var l = this.pad + niter.get_key() + " : " +
- this.mungeChildNew(this.pad + indent_str, niter.get_value()) + suffix;
- this.addMultiLine(l);
+ var addstr = this.mungeChildNew(this.pad + indent_str, niter.get_value());
+ this.node.setLine(this.cur_line, "p",niter.get_key());
+ this.addLine(this.pad + niter.get_key() + " : " + addstr, ',');
+
+ this.node.setLine(this.cur_line, "e", "");
}
// prop arrays...
var piter = this.out_props_array.map_iterator();
while(piter.next()) {
- total_nodes--;
-
- this.addLine(this.pad + piter.get_key() + " : [");
+ this.node.setLine(this.cur_line, "p",niter.get_key());
+ this.addLine(this.pad + piter.get_key() + " : [", 0);
+
var pliter = piter.get_value().list_iterator();
while (pliter.next()) {
- suffix = pliter.has_next() ? "," : "";
- this.addMultiLine(this.pad + indent_str +
- this.mungeChildNew(this.pad + indent_str + indent_str, pliter.get()) + suffix);
+ var addstr = this.mungeChildNew(this.pad + indent_str + indent_str, pliter.get());
+ this.addLine(this.pad + indent_str + addstr, ',');
+ this.node.setLine(this.cur_line, "e", "");
}
-
- suffix = total_nodes > 0 ? "," : "";
-
- this.addLine(this.pad + "]" + suffix);
+ this.closeLine();
+ this.addLine(this.pad + "]" , ',');
}
// children..
if (this.out_children.size > 0) {
- this.addLine(this.pad + "items : [" );
+ this.addLine(this.pad + "items : [" , 0);
var cniter = this.out_children.list_iterator();
while (cniter.next()) {
suffix = cniter.has_next() ? "," : "";
- this.addMultiLine(this.pad + indent_str +
- this.mungeChildNew(this.pad + indent_str + indent_str, cniter.get()) + suffix
- );
+ var addstr = this.mungeChildNew(this.pad + indent_str + indent_str, cniter.get());
+ this.addLine(this.pad + indent_str + addstr, ',');
+ this.node.setLine(this.cur_line, "e", "");
}
-
- this.addLine(this.pad + "]");
+ this.closeLine();
+ this.addLine(this.pad + "]",',');
}
-
+ this.node.setLine(this.cur_line, "e", "");
+ this.closeLine();
if (this.node.props.has_key("* xinclude")) {
- this.ret += spad + "})";
+ this.addLine(spad + "})",0);
} else {
- this.ret += spad + "}";
+ this.addLine( spad + "}", 0);
}
this.node.sortLines();
+
+
+
return this.ret;
}
-
-
-
+ /**
+ * Line endings
+ * if we end with a ','
+ *
+ */
+
+ char last_line_end = '!';
- public void addLine(string str= "")
+ /**
+ * add a line - note we will end up with an extra line break
+ * at beginning of nodes doing this..
+ *
+ * @param str = text to add..
+ * @param line_end = 0 (just add a line break)
+ * line_end = ',' and ","
+ *
+ */
+ public void addLine(string str, char line_end)
{
- this.cur_line ++;
- this.ret += str+ "\n";
+ if (this.last_line_end != '!') {
+ this.ret += (this.last_line_end == 0 ? "" : this.last_line_end.to_string()) + "\n";
+ }
+ this.last_line_end = line_end;
+ this.cur_line += str.split("\n").length;
+ this.ret += str;
+
+
//this.ret += "/*%d(%d-%d)*/ ".printf(this.cur_line -1, this.node.line_start,this.node.line_end) + str + "\n";
}
+ public void closeLine() // send this before '}' or ']' to block output of ',' ...
+ {
+ this.last_line_end = 0;
+ }
- public void addMultiLine(string str= "")
+/* public void addMultiLine(str= "")
{
-
- //this.ret += "/*%d(%d-%d)*/ ".printf(this.cur_line, this.node.line_start,this.node.line_end)+ str + "\n";
+
+ //this.ret += "/ * %d(%d-%d) * / ".printf(this.cur_line, this.node.line_start,this.node.line_end)+ str + "\n";
this.ret += str + "\n";
this.cur_line += str.split("\n").length;
}
-
+ */
public string mungeChildNew(string pad , Node cnode )
{
var x = new NodeToJs(cnode, this.doubleStringProps, pad, this);
return x.ret;
}
-
+ /**
+ * loop through items[] array see if any of the children have '* prop'
+ * -- which means they are a property of this node.
+ * -- ADD TO : this.opt_props_array
+ *
+ */
public void checkChildren ()
{
//var prop = pl['*prop'] + '';
//delete pl['*prop'];
var prop = pl.get("* prop");
- print("got prop "+ prop + "\n");
+ //print("got prop "+ prop + "\n");
// name ends in [];
if (! Regex.match_simple("\\[\\]$", prop)) {
var sprop = prop.replace("[]", "");
- print("sprop is : " + sprop + "\n");
+ //print("sprop is : " + sprop + "\n");
// it's an array type..
//var old = "";
{
string left;
Regex func_regex ;
-
- if (this.node.props.has_key("$ xns")) {
- this.out_props.set("'|xns'", "'" + this.node.props.get("$ xns") + "'" );
-
- //this.els.add("'|xns' : '" + this.node.props.get("$ xns") + "'");
-
- }
-
-
+
try {
func_regex = new Regex("^\\s+|\\s+$");
} catch (RegexError e) {
for (var i = 0; i< keys.size; i++) {
var key = this.node.get_key(keys.get(i));
- print("ADD KEY %s\n", key);
+ //("ADD KEY %s\n", key);
string k;
string ktype;
string kflag;
//nstr = string.joinv("\n", lines);
}
this.out_props.set(left, nstr);
+
+
+
+
+
//print("==> " + str + "\n");
//this.els.add(left + " : "+ nstr);
continue;
/**
*
- * Code to convert node tree to Javascript...
+ * Code to convert node tree to Vala...
*
- * usage : x = (new JsRender.NodeToJs(node)).munge();
+ * usage : x = (new JsRender.NodeToVala(node)).munge();
*
*
*
}
-
+ public override string toSourceCode()
+ {
+ return this.contents;
+
+
+
+ }
public override void save() {
if (!this.loaded) {
print("Ignoring Save - as file was never loaded?\n");
{
- print("load Items!");
+ GLib.debug("load Items!");
if (this.tree != null) {
return;
}
- print("load " + this.path);
+ GLib.debug("load " + this.path);
var pa = new Json.Parser();
pa.load_from_file(this.path);
public override void save()
{
- print("--- JsRender.Roo.save");
- print("save() - reset transStrings\n");
+ GLib.debug("--- JsRender.Roo.save");
+ GLib.debug("save() - reset transStrings\n");
this.transStrings = new Gee.HashMap<string,string>();
this.findTransStrings(this.tree);
{
var top = this.tree.fqn();
- print ("TOP = " + top + "\n" );
- if (top.index_of("Roo.bootstrap.") < 0 &&
- top.index_of("Roo.mailer.") < 0
- ) {
- return;
- }
+ GLib.debug ("TOP = " + top + "\n" );
+ if (top.index_of("Roo.bootstrap.") < 0 &&
+ top.index_of("Roo.mailer.") < 0
+ ) {
+ return;
+ }
//now write the js file..
print("Skip save - templates folder does not exist : %s\n", targetdir);
return;
}
- print("SAVE HTML -- %s\n%s\n",targetdir + "/" + bn, html);
+ //print("SAVE HTML -- %s\n%s\n",targetdir + "/" + bn, html);
try {
this.writeFile(targetdir + "/" + bn , html);
} catch (FileError e ) {
var str = iter.get_value();
if (this.doubleStringProps.index_of(kname) > -1) {
- print("flag=%s type=%s name=%s : %s\n", kflag,ktype,kname,str);
+ GLib.debug("flag=%s type=%s name=%s : %s\n", kflag,ktype,kname,str);
this.transStrings.set(str,
GLib.Checksum.compute_for_string (ChecksumType.MD5, str.strip())
);
}
if (ktype.down() == "string" && kname[0] == '_') {
- print("flag=%s type=%s name=%s : %s\n", kflag,ktype,kname,str);
+ GLib.debug("flag=%s type=%s name=%s : %s\n", kflag,ktype,kname,str);
this.transStrings.set(str,
GLib.Checksum.compute_for_string (ChecksumType.MD5, str.strip())
);
public string transStringsToJs()
{
- print("Roo.transStringsToJs()\n");
+ GLib.debug("Roo.transStringsToJs()\n");
if (this.transStrings.size < 1) {
- print("Roo.transStringsToJs() size < 1?\n");
+ GLib.debug("Roo.transStringsToJs() size < 1?\n");
return "";
}
*
*
*/
+ public override string toSourceCode()
+ {
+ this.transStrings = new Gee.HashMap<string,string>();
+ this.findTransStrings(this.tree);
+ return this.toSource();
+ }
+
public override string toSource()
{
// dump the file tree back out to a string.
-
+ new JsRender.Lang_Class();
var app = BuilderApplication.singleton( args);
});
}
- if (BuilderApplication.opt_compile_project != null) {
+
+ if (BuilderApplication.opt_list_projects) {
+
+ //BuilderApplication.compileBjs();
+ Project.Project.loadAll();
+ print("Projects\n %s\n", Project.Project.listAllToString());
+ GLib.Process.exit(Posix.EXIT_SUCCESS);
+ }
+ Project.Project.loadAll();
+
+ if (BuilderApplication.opt_list_projects) {
+
+ //BuilderApplication.compileBjs();
+
+ print("Projects\n %s\n", Project.Project.listAllToString());
+ GLib.Process.exit(Posix.EXIT_SUCCESS);
+ }
+ Project.Project cur_project = null;
+ if (BuilderApplication.opt_compile_project != null) {
+
+
+ cur_project = Project.Project.getProjectByHash( BuilderApplication.opt_compile_project);
+
+ if (cur_project == null) {
+ GLib.error("invalid project %s, use --list-projects to show project ids",BuilderApplication.opt_compile_project);
+ }
+ cur_project.scanDirs();
+
+
+ }
+
+ if (BuilderApplication.opt_list_files) {
+ if (cur_project == null) {
+ GLib.error("missing project, use --project to select which project");
+ }
+ print("Files for %s\n %s\n", cur_project.name, cur_project.listAllFilesToString());
+ GLib.Process.exit(Posix.EXIT_SUCCESS);
+ }
+
+ if (BuilderApplication.opt_bjs_compile != null) {
+ if (cur_project == null) {
+ GLib.error("missing project, use --project to select which project");
+ }
+ var file = cur_project.getByName(BuilderApplication.opt_bjs_compile);
+ if (file == null) {
+ GLib.error("missing file %s in project %s", BuilderApplication.opt_bjs_compile, cur_project.name);
+ }
+ //BuilderApplication.compileBjs();
+ file.loadItems();
+ var str = file.toSourceCode();
+
+
+ if (!BuilderApplication.opt_debug) {
+ print("%s", str);
+ GLib.Process.exit(Posix.EXIT_SUCCESS);
+ }
+
+ // dump the node tree
+ file.tree.dumpProps();
+
+
+ var str_ar = str.split("\n");
+ for(var i =0;i<str_ar.length;i++) {
+ var node = file.tree.lineToNode(i+1);
+ var prop = node == null ? null : node.lineToProp(i+1);
+ print("%d: %s : %s\n",
+ i+1,
+ node == null ? "......" : (prop == null ? "????????" : prop),
+ str_ar[i]
+ );
+ }
+
+ GLib.Process.exit(Posix.EXIT_SUCCESS);
+ }
+
+
+ if (BuilderApplication.opt_compile_target != null) {
Palete.ValaSourceCompiler.buildApplication();
GLib.debug("project = %s\n", BuilderApplication.opt_compile_project);
Gtk.init (ref args);
-
-
+
GtkClutter.init (ref args);
- new JsRender.Lang_Class();
+
GLib.Log.set_always_fatal(LogLevelFlags.LEVEL_ERROR | LogLevelFlags.LEVEL_CRITICAL);
- Project.Project.loadAll();
+
+
+
+ // respond to other arguments
+
/*var proj = Project.Project.getProject("Pman.Core");
if (proj == null) {
print("could not load test project Pman.Core");
builder_LIBVALA = --pkg libvala-0.24
endif
-
if HAVE_LIBVALA26
builder_LIBVALA = --pkg libvala-0.26
endif
builder_LIBVALA = --pkg libvala-0.30
endif
+if HAVE_LIBVALA32
+builder_LIBVALA = --pkg libvala-0.32
+endif
+
# gda
--pkg posix
-builder4_SOURCES = \
- Application.vala \
- Main.vala \
- Spawn.vala \
- JsRender/Gtk.vala \
+BUIDERJSRENDER = \
+ JsRender/Gtk.vala \
JsRender/PlainFile.vala \
JsRender/JsRender.vala \
JsRender/Lang.vala \
JsRender/NodeToJs.vala \
JsRender/NodeToVala.vala \
JsRender/Node.vala \
- JsRender/Roo.vala \
- Project/Gtk.vala \
- Project/Project.vala \
- Project/Roo.vala \
- Palete/Gir.vala \
+ JsRender/Roo.vala
+
+BUIDERPALETE = \
+ Palete/Gir.vala \
Palete/GirObject.vala \
Palete/VapiParser.vala \
Palete/Gtk.vala \
Palete/RooDatabase.vala \
- c/jscore_object_call_as_function.c \
+ c/jscore_object_call_as_function.c \
Palete/Javascript.vala \
Palete/Palete.vala \
Palete/Roo.vala \
Palete/ValaSource.vala \
Palete/ValaSourceCompiler.vala \
- Palete/CompletionProvider.vala \
- Builder4/About.vala \
+ Palete/CompletionProvider.vala
+
+BUIDERPROJECT = \
+ Project/Gtk.vala \
+ Project/Project.vala \
+ Project/Roo.vala
+
+
+BUIDERUI = \
+ Builder4/About.vala \
Builder4/DialogConfirm.vala \
Builder4/StandardErrorDialog.vala \
Builder4/DialogSaveTemplate.vala \
Builder4/PopoverFileDetails.vala \
Builder4/ValaCompileErrors.vala \
Builder4/ValaCompileResults.vala \
- Builder4/PopoverProperty.vala \
- Resources.vala
+ Builder4/PopoverProperty.vala
+
+builder4_SOURCES = \
+ Application.vala \
+ Main.vala \
+ Spawn.vala \
+ Resources.vala \
+ $(BUIDERJSRENDER) \
+ $(BUIDERPALETE) \
+ $(BUIDERPROJECT) \
+ $(BUIDERUI) \
+
+
+
context.experimental = false;
context.experimental_non_null = false;
-#if VALA_0_30
+#if VALA_0_32
+ var ver=32;
+#elif VALA_0_30
var ver=30;
#elif VALA_0_28
var ver=28;
var cc_command = Environment.get_variable ("CC");
- string [] cc_options = { "-lm" };
- valac += " -X -lm";
+ string [] cc_options = { "-lm", "-pg" };
+ valac += " -X -lm -X -pg";
-#if VALA_0_28 || VALA_0_30
+#if VALA_0_28 || VALA_0_30 || VALA_0_32
var pkg_config_command = Environment.get_variable ("PKG_CONFIG");
ccompiler.compile (context, cc_command, cc_options, pkg_config_command);
#else
context.experimental = false;
context.experimental_non_null = false;
-#if VALA_0_30
+#if VALA_0_32
+ var ver=32;
+#elif VALA_0_30
var ver=30;
#elif VALA_0_28
var ver=28;
return null;
}
+
+ public static string listAllToString()
+ {
+ var all = new Gee.ArrayList<Project>();
+
+ var fiter = projects.map_iterator();
+
+ while(fiter.next()) {
+ all.add(fiter.get_value());
+ }
+
+ all.sort((fa,fb) => {
+ return ((Project)fa).name.collate(((Project)fb).name);
+
+ });
+
+ var iter = all.list_iterator();
+ var ret = "ID\tName\tDirectory\n";
+ while (iter.next()) {
+ ret += "%s\t%s\t%s\n".printf(
+ iter.get().fn,
+ iter.get().name,
+ iter.get().firstPath()
+ );
+
+
+ }
+
+ return ret;
+
+ }
+
+
+
public static Project getProjectByHash(string fn)
{
}
+
+ public string listAllFilesToString()
+ {
+ this.scanDirs();
+ var iter = this.sortedFiles().list_iterator();
+ var ret = "ID\tName\tDirectory\n";
+ while (iter.next()) {
+ ret += "%s\n".printf(
+
+ iter.get().name
+
+ );
+
+
+ }
+
+ return ret;
+
+ }
+
+
+
+
public JsRender.JsRender? getByName(string name)
{