Fix #8028 - language server performance, fix warnings and critical errors
[roobuilder] / src / Builder4 / DialogFiles.bjs
index ec42b33..2fe4f40 100644 (file)
@@ -5,6 +5,42 @@
   {
    "# Xcls_MainWindow win" : "",
    "$ xns" : "Gtk",
+   "* init" : [
+    "{",
+    "\tvar ev = new Gtk.EventControllerKey();",
+    "\tev.propagation_phase = Gtk.PropagationPhase.CAPTURE;",
+    "\t// my vars (dec)",
+    "",
+    "\t// set gobject values",
+    "",
+    "\t//listeners",
+    "\tev.key_released.connect( (keyval, keycode, state) => {",
+    "\t",
+    "\t\t// GLib.debug(\"key pressed %d\", (int)keycode);",
+    "\t\tif (keycode != 9) {",
+    "\t\t\treturn   ;",
+    "\t\t}",
+    "\t\tif (BuilderApplication.windows.size < 2 && ",
+    "\t\t\t_this.win.windowstate.file == null",
+    "\t\t) { ",
+    "\t\t\tBuilderApplication.singleton(null).quit();",
+    "\t\t\treturn  ;",
+    "\t\t}",
+    "\t",
+    "\t\t_this.el.hide();",
+    "\t\t",
+    "\t\t if (_this.win.windowstate.file == null) {\t\t ",
+    "\t\t\tBuilderApplication.removeWindow(_this.win);",
+    "\t\t\t    ",
+    "\t\t}",
+    "\t",
+    "\t\treturn  ;",
+    "\t});",
+    "\tev.ref(); //?? needed?",
+    "\t((Gtk.Widget)this.el).add_controller(ev);",
+    "}",
+    ""
+   ],
    "Gdk.Pixbuf missing_thumb_pixbuf" : "",
    "Gee.HashMap<string,Gdk.Pixbuf> image_cache" : "",
    "Project.Project selectedProject" : "",
          "items" : [
           {
            "$ xns" : "Gtk",
-           "* init" : [
-            "{",
-            " ",
-            "\tthis.css = new Gtk.CssProvider();",
-            " ",
-            "\tthis.css.load_from_string(\"",
-            "\t\t#project-list { font-size: 12px;}",
-            "\t\");",
-            "",
-            "\tGtk.StyleContext.add_provider_for_display(",
-            "\t\tthis.el.get_display(),",
-            "\t\tthis.css,",
-            "\t\tGtk.STYLE_PROVIDER_PRIORITY_APPLICATION",
-            "\t);",
-            "\t\t",
-            "   ",
-            "}",
-            ""
-           ],
            "* prop" : "child",
            "Gtk.CssProvider css" : "",
            "id" : "project_list",
                     "\tvar str = _this.searchbox.el.text.down();\t",
                     "\tif (j.xtype == \"Dir\") {",
                     "\t",
-                    "\t\tif (str.length < 1) {",
-                    "\t\t\treturn true;",
-                    "\t\t}",
+                    "\t\t",
                     "\t\tfor (var i =0 ; i < j.childfiles.n_items; i++) {",
                     "\t\t\tvar f = (JsRender.JsRender) j.childfiles.get_item(i);",
                     "\t\t\tif (f.xtype != \"PlainFile\") {",
                     "\t\t\t\tcontinue;",
                     "\t\t\t}",
+                    "\t\t\tif (f.content_type.contains(\"image\")) {",
+                    "\t\t\t\tcontinue;",
+                    "\t\t\t}",
+                    "\t\t\tif (str.length < 1) {",
+                    "\t\t\t\treturn true;",
+                    "\t\t\t}",
                     "\t\t\tif (f.name.down().contains(str)) {",
                     "\t\t\t\treturn true;",
                     "\t\t\t}",
+                    "\t\t\t",
                     "\t\t}",
+                    "\t\t ",
                     "\t\treturn false;",
                     "\t}",
                     "\tif (j.xtype != \"PlainFile\") {",
                     "\t\treturn false;",
                     "\t}",
-                    "",
-                    "\tif (str.length < 1) {",
+                    " \tif (j.content_type.contains(\"image\")) {",
+                    "\t\treturn false;",
+                    "\t}",
+                    "\t\t\t ",
+                    "\tif (str.length < 1) { // no search.",
                     "\t\treturn true;",
                     "\t}",
                     "\tif (j.name.down().contains(str)) {",
           }
          ],
          "xtype" : "Paned"
+        },
+        {
+         "$ xns" : "Gtk",
+         "listeners" : {
+          "key_pressed" : [
+           "(keyval, keycode, state) => {",
+           "",
+           "\tif (keycode != Gdk.Key.Escape) {",
+           "\t\treturn true;",
+           "\t}",
+           "\tif (BuilderApplication.windows.size < 2 && ",
+           "\t\t_this.win.windowstate.file == null",
+           "\t) { ",
+           "\t\tBuilderApplication.singleton(null).quit();",
+           "\t\treturn true;",
+           "\t}",
+           "",
+           "\t_this.el.hide();",
+           "\t",
+           "\t if (_this.win.windowstate.file == null) {\t\t ",
+           "\t\tBuilderApplication.removeWindow(_this.win);",
+           "\t\t    ",
+           "\t}",
+           "",
+           "\treturn true;",
+           "}",
+           ""
+          ]
+         },
+         "xtype" : "EventControllerKey"
         }
        ],
        "xtype" : "Paned"
    "xtype" : "Window",
    "| void load" : [
     "() {",
-    "     // clear list...",
+    "     // cl list...",
     "    ",
     "       ",
     "     _this.is_loading = true;",
-    "         ",
+    "        ",
     "",
     "     Project.Project.loadAll();",
     "     _this.project_list.el.set_model(new Gtk.SingleSelection(null));",
     "    ",
     "    _this.projectselection.el.selected = Gtk.INVALID_LIST_POSITION; ",
     "\t_this.btn_delfile.el.hide();",
-    "\t",
+    " ",
     "  ",
     "}",
     ""