Fix #8046 - meson generation option (so we can edit the language server..)
[roobuilder] / src / Builder4 / ValaProjectSettingsPopover.bjs
index 7eb6815..9299b40 100644 (file)
@@ -3,13 +3,13 @@
  "gen_extended" : false,
  "items" : [
   {
+   "# Project.Gtk project" : "null",
+   "# Project.GtkValaSettings? selected_target" : "null",
+   "# Xcls_MainWindow window" : "null",
+   "# bool cg_loading" : false,
+   "# bool done" : false,
    "$ Project.Callback doneObj" : "null",
    "$ xns" : "Gtk",
-   "Project.Gtk project" : "null",
-   "Project.GtkValaSettings? selected_target" : "null",
-   "Xcls_MainWindow window" : "null",
-   "bool cg_loading" : false,
-   "bool done" : false,
    "bool modal" : true,
    "items" : [
     {
          "items" : [
           {
            "$ xns" : "Gtk",
-           "Gtk.Align halign" : "Gtk.Align.START",
-           "bool hexpand" : true,
-           "utf8 label" : "compile flags",
-           "xtype" : "Label"
+           "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
+           "int spacing" : 10,
+           "items" : [
+            {
+             "$ xns" : "Gtk",
+             "Gtk.Align halign" : "Gtk.Align.START",
+             "bool hexpand" : false,
+             "utf8 label" : "Compile flags:",
+             "xtype" : "Label"
+            },
+            {
+             "$ xns" : "Gtk",
+             "id" : "compile_flags",
+             "listeners" : {
+              "changed" : [
+               "() => {",
+               "    ",
+               "   _this.project.compile_flags = this.el.buffer.text;",
+               "   _this.project.save();",
+               "//    _this.project.save();",
+               "",
+               "}"
+              ]
+             },
+             "utf8 placeholder_text" : "eg. -g --valasrc $BASEDIR ",
+             "xtype" : "Entry"
+            },
+            {
+             "$ xns" : "Gtk",
+             "id" : "generate_meson",
+             "listeners" : {
+              "activate" : [
+               "( ) => {",
+               "",
+               "\t_this.project.generate_meson = this.el.active;",
+               "}",
+               "\t"
+              ]
+             },
+             "string label" : "Generate Meson",
+             "xtype" : "CheckButton"
+            }
+           ],
+           "xtype" : "Box"
           },
           {
            "$ xns" : "Gtk",
-           "id" : "compile_flags",
-           "listeners" : {
-            "changed" : [
-             "() => {",
-             "    ",
-             "   _this.project.compile_flags = this.el.buffer.text;",
-             "   _this.project.save();",
-             "//    _this.project.save();",
-             "",
-             "}"
-            ]
-           },
-           "utf8 placeholder_text" : "eg. -g --valasrc $BASEDIR ",
-           "xtype" : "Entry"
+           "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
+           "int spacing" : 10,
+           "items" : [
+            {
+             "$ xns" : "Gtk",
+             "Gtk.Align halign" : "Gtk.Align.START",
+             "bool hexpand" : false,
+             "utf8 label" : "Version:",
+             "xtype" : "Label"
+            },
+            {
+             "$ xns" : "Gtk",
+             "id" : "version",
+             "listeners" : {
+              "changed" : [
+               "() => {",
+               "    ",
+               "   _this.project.version = this.el.buffer.text;",
+               "   _this.project.save();",
+               "//    _this.project.save();",
+               "",
+               "}"
+              ]
+             },
+             "utf8 placeholder_text" : "eg. 1.5",
+             "xtype" : "Entry"
+            },
+            {
+             "$ xns" : "Gtk",
+             "Gtk.Align halign" : "Gtk.Align.START",
+             "bool hexpand" : false,
+             "utf8 label" : "Licence:",
+             "xtype" : "Label"
+            },
+            {
+             "$ xns" : "Gtk",
+             "id" : "licence",
+             "listeners" : {
+              "changed" : [
+               "() => {",
+               "    ",
+               "   _this.project.licence = this.el.buffer.text;",
+               "   _this.project.save();",
+               "//    _this.project.save();",
+               "",
+               "}"
+              ]
+             },
+             "utf8 placeholder_text" : "eg. LGPL",
+             "xtype" : "Entry"
+            }
+           ],
+           "xtype" : "Box"
           },
           {
            "$ xns" : "Gtk",
                   "\t GLib.debug(\"Set name to %s\", cg.name);",
                   "\t ",
                   " \t_this.build_name.el.buffer.set_text(cg.name.data);",
-                  " ",
+                  " \t_this.build_as_library.el.active = cg.is_library;",
                   " ",
                   "\t_this.build_execute_args.el.buffer.set_text(  cg.execute_args.data );",
                   " ",
                "xtype" : "Label"
               },
               {
+               "# bool in_insert" : false,
                "$ xns" : "Gtk",
+               "* init" : [
+                "",
+                "var ed = (this.el.get_delegate() as Gtk.Editable);",
+                "if (ed != null) {",
+                "\ted.insert_text.connect((text, length, ref position) => {",
+                "\t\tif (this.in_insert) {",
+                "\t\t\treturn;",
+                "\t\t}",
+                "\t\tGLib.debug(\"got insert text %s\", text);",
+                "\t\t",
+                "\t\tvar nt = \"\";",
+                "\t\tfor(var i = 0;i < text.length; i++){ ",
+                "\t\t\tif (Posix.isupper(text[i]) ||Posix.islower(text[i])  ) {",
+                "\t\t\t\tnt +=  text[i].to_string();",
+                "\t\t\t}\t",
+                "\t\t}",
+                "\t\tif (nt.length < 1) {",
+                "\t\t\tGLib.Signal.stop_emission_by_name(ed, \"insert_text\");",
+                "\t\t\treturn;",
+                "\t\t}",
+                "",
+                "\t\tthis.in_insert = true;",
+                "\t ",
+                "\t\tthis.el.insert_text(nt,nt.length, ref position);",
+                "\t\tthis.in_insert = false;",
+                "\t\tGLib.Signal.stop_emission_by_name(ed, \"insert_text\");",
+                "\t});",
+                "",
+                "}"
+               ],
                "id" : "build_name",
                "listeners" : {
                 "changed" : [
                  "",
                  "\t_this.selected_target.name = this.el.buffer.text;",
                  "}"
+                ],
+                "insert_text" : [
+                 "(text, length, ref position) => {",
+                 "\tif (this.in_insert) {",
+                 "\t\treturn;",
+                 "\t}",
+                 "\tGLib.debug(\"got insert text %s\", text);",
+                 "\t",
+                 "\tvar nt = \"\";",
+                 "\tfor(var i = 0;i < text.length; i++){ ",
+                 "\t\tif (Posix.isalpha(text[i])) {",
+                 "\t\t\tnt +=  text[i].to_string();",
+                 "\t\t}\t",
+                 "\t}",
+                 "\tif (nt.length < 1) {",
+                 "\t\treturn;",
+                 "\t}",
+                 "",
+                 "\tthis.in_insert = true;",
+                 " ",
+                 "\tthis.el.insert_text(text,length, ref position);",
+                 "\tthis.in_insert = false;",
+                 "}",
+                 ""
                 ]
                },
                "xtype" : "Entry"
                },
                "string placeholder_text" : "eg.  -f somefile -g ",
                "xtype" : "Entry"
+              },
+              {
+               "$ xns" : "Gtk",
+               "id" : "build_as_library",
+               "listeners" : {
+                "notify[\"active\"]" : [
+                 "() => {",
+                 "    if (_this.selected_target == null) {",
+                 "        return;",
+                 "    }",
+                 "    _this.selected_target.is_library = this.el.active;",
+                 "    ",
+                 "}",
+                 ""
+                ]
+               },
+               "string label" : "build as library",
+               "xtype" : "CheckButton"
               }
              ],
              "xtype" : "Box"
     "    this.compile_flags.el.buffer.set_text(",
     "    \tproject.compile_flags.data",
     "\t);",
-    "\t   ",
+    "   this.version.el.buffer.set_text(",
+    "    \tproject.version.data",
+    "\t);",
+    "\t  this.licence.el.buffer.set_text(",
+    "    \tproject.licence.data",
+    "\t); ",
     "    project.loadVapiIntoStore(_this.vapimodel.el);",
     "     GLib.Timeout.add(500, () => {",
     " \t\t this.vapi_scroll.el.vadjustment.value  = 0;\t ",
     "\t     return false;",
     "     });",
     "    ",
-    "   ",
+    "   this.generate_meson.el.active = this.project.generate_meson;",
     " \t",
     " \tproject.loadTargetsIntoStore(this.target_model.el);",
     "\t",