expanding tree when error buttons pressed
[roobuilder] / src / Builder4 / MainWindow.bjs
index 8c49c04..34980b1 100644 (file)
@@ -6,6 +6,7 @@
    "# Project.Project project" : "null",
    "# WindowState windowstate" : "",
    "# bool winloading" : false,
+   "# default_height" : 850,
    "$ type" : "Gtk.WindowType.TOPLEVEL",
    "$ xns" : "Gtk",
    "* ctor" : "new Gtk.ApplicationWindow(BuilderApplication.singleton({}))",
@@ -15,7 +16,6 @@
     ""
    ],
    "border_width" : 0,
-   "default_height" : 850,
    "default_width" : 1200,
    "id" : "MainWindow",
    "items" : [
                  "listeners" : {
                   "bind" : [
                    "(listitem) => {",
-                   "\t var lb = (Gtk.Label) (listitem as Gtk.ListItem).get_child();",
-                   "\t var item =  (listitem as Gtk.ListItem).get_item() as WindowState;",
-                   "\t ",
+                   "\tvar li = (listitem as Gtk.ListItem);",
+                   "\tif (li == null) {",
+                   "\t\treturn;",
+                   "\t}",
+                   "\t var lb = (Gtk.Label) li.get_child() as Gtk.Label;",
+                   "\t if (lb == null) {",
+                   "\t \treturn;",
+                   " \t}",
+                   "\t var item =  li.get_item() as WindowState;",
+                   "\t if (item == null) {",
+                   "\t \treturn;",
+                   " \t}",
                    "\t lb.label = item.project.name;",
                    "",
                    "",
                   ],
                   "setup" : [
                    "(listitem) => {",
+                   "",
+                   "\tvar li = (listitem as Gtk.ListItem);",
+                   "\tif (li == null) {",
+                   "\t\treturn;",
+                   "\t}",
+                   "",
                    "\tvar lbl = new Gtk.Label(\"\");",
-                   " \t(listitem as Gtk.ListItem).set_child(lbl);",
+                   " \tli.set_child(lbl);",
                    " \tlbl.justify = Gtk.Justification.LEFT;",
                    " \tlbl.xalign = 0;",
                    " \tlbl.use_markup = true;",
                    "\tlbl.ellipsize = Pango.EllipsizeMode.START;",
                    "  ",
-                   "\t(listitem as Gtk.ListItem).activatable = true;",
+                   "\tli.activatable = true;",
                    "}",
                    ""
                   ]
                  "listeners" : {
                   "bind" : [
                    "(listitem) => {",
-                   " var lb = (Gtk.Label) (listitem as Gtk.ListItem).get_child();",
-                   " var item =  (listitem as Gtk.ListItem).get_item() as WindowState;",
-                   " ",
-                   " lb.label = item.file.relpath;",
+                   "\tvar li = (listitem as Gtk.ListItem);",
+                   "\tif (li == null) {",
+                   "\t\treturn;",
+                   "\t}",
+                   "\t var lb = (Gtk.Label) li.get_child() as Gtk.Label;",
+                   "\t if (lb == null) {",
+                   "\t \treturn;",
+                   " \t}",
+                   "\t var item =  li.get_item() as WindowState;",
+                   "\t if (item == null) {",
+                   "\t \treturn;",
+                   " \t}",
+                   " \t",
+                   " \t ",
+                   "  ",
+                   " \tlb.label = item.file.relpath;",
                    "",
                    "",
                    "  ",
                   ],
                   "setup" : [
                    "(listitem) => {",
+                   "\tvar li = (listitem as Gtk.ListItem);",
+                   "\tif (li == null) {",
+                   "\t\treturn;",
+                   "\t}",
                    "\tvar lbl = new Gtk.Label(\"\");",
-                   " \t(listitem as Gtk.ListItem).set_child(lbl);",
+                   " \tli.set_child(lbl);",
                    " \tlbl.justify = Gtk.Justification.LEFT;",
                    " \tlbl.xalign = 0;",
                    " \tlbl.use_markup = true;",
                    "\tlbl.ellipsize = Pango.EllipsizeMode.START;",
                    "  ",
-                   "\t(listitem as Gtk.ListItem).activatable = true;",
+                   "\tli.activatable = true;",
                    "}",
                    ""
                   ]
      "\t BuilderApplication.removeWindow(this);",
      "\t ",
      "\t if (BuilderApplication.windows.size  < 1) {",
-     "\t\tthis.windowstate.file.getLanguageServer().exit();",
+     "\t \ttry {",
+     "\t\t\tthis.windowstate.file.getLanguageServer().exit();",
+     "\t\t} catch(Error e) {}",
+     "\t\t",
      "\t\tBuilderApplication.singleton(  null ).quit();",
      "\t }",
      "\treturn true;",