Fix #8025 - move css to resources
[roobuilder] / src / Builder4 / DialogFiles.bjs
index 1ecf130..880c48b 100644 (file)
          "items" : [
           {
            "$ xns" : "Gtk",
-           "* init" : [
-            "{",
-            " ",
-            "\tthis.css = new Gtk.CssProvider();",
-            " ",
-            "\tthis.css.load_from_string(\"#project-list { font-size: 12px;}\");",
-            "",
-            "\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 lbl = (Gtk.Label)  ((Gtk.ListItem)listitem).get_child();",
                  "\t   ",
-                 "\tvar item = (JsRender.JsRender)  ((Gtk.ListItem)listitem).get_item();",
+                 "\tvar item = (Project.Project)  ((Gtk.ListItem)listitem).get_item();",
                  "",
                  "\titem.bind_property(\"name\",",
                  "                lbl, \"label\",",
               " ",
               "\tthis.css = new Gtk.CssProvider();",
               " ",
-              "\tthis.css.load_from_string(\"#file-list { font-size: 12px;}\");",
+              "\tthis.css.load_from_string(\"",
+              "#file-list { font-size: 12px;}",
+              "#file-list indent {",
+              "-gtk-icon-size : 2px;",
+              "}",
+              "#file-list indent:nth-last-child(2)  {",
+              "min-width: 24px;",
+              "}",
+              "\");",
               "",
               "\tGtk.StyleContext.add_provider_for_display(",
               "\t\tthis.el.get_display(),",
                     "\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)) {",
                  "listeners" : {
                   "bind" : [
                    "(listitem) => {",
-                   "\t //GLib.debug(\"listitme is is %s\", ((Gtk.ListItem)listitem).get_type().name());",
-                   "\t",
                    "\t",
-                   "\t",
-                   "\t//var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();",
-                   "\tvar expand = (Gtk.TreeExpander)  ((Gtk.ListItem)listitem).get_child();",
-                   "\t  ",
+                   "\t //GLib.debug(\"listitme is is %s\", ((Gtk.ListItem)listitem).get_type().name());",
+                   "                \t",
+                   "            \t",
+                   "            \t",
+                   "        \t//var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();",
+                   "    \tvar expand = (Gtk.TreeExpander)  ((Gtk.ListItem)listitem).get_child();",
+                   "    \t  ",
+                   "     \tvar hbox = (Gtk.Box) expand.child;",
                    " ",
-                   "\tvar lbl = (Gtk.Label) expand.child;",
                    "\t",
-                   "\t if (lbl.label != \"\") { // do not update",
-                   "\t \treturn;",
-                   " \t}",
-                   "\tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();",
-                   "\t//GLib.debug(\"LR = %s\", lr.get_type().name());",
+                   "\t\tvar img = (Gtk.Image) hbox.get_first_child();",
+                   "\t\tvar lbl = (Gtk.Label) img.get_next_sibling();",
                    "",
-                   "\t",
-                   "\tvar jr =(JsRender.JsRender) lr.get_item();",
-                   "\t//GLib.debug(\"JR = %s\", jr.get_type().name());\t\t",
-                   "\t",
-                   "\t if (jr == null) {",
-                   "\t\t GLib.debug(\"Problem getting item\"); ",
-                   "\t\t return;",
-                   "\t }",
-                   "\t//GLib.debug(\"change  %s to %s\", lbl.label, np.name);",
-                   "\tlbl.label = jr.name; // for dir's we could hsow the sub path..",
-                   "\tlbl.tooltip_markup = jr.path;",
-                   "\t ",
-                   "    expand.set_hide_expander(  jr.xtype != \"Dir\" );",
-                   " \t expand.set_list_row(lr);",
                    " ",
-                   " \t ",
-                   " \t// bind image...",
-                   " \t",
-                   "}",
+                   "    \t",
+                   "    \t if (lbl.label != \"\") { // do not update",
+                   "    \t \treturn;",
+                   "     \t}",
+                   "    \tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();",
+                   "    \t//GLib.debug(\"LR = %s\", lr.get_type().name());",
+                   "    ",
+                   "    \t",
+                   "    \tvar jr =(JsRender.JsRender) lr.get_item();",
+                   "    \t//GLib.debug(\"JR = %s\", jr.get_type().name());\t\t",
+                   "    \t",
+                   "    \t if (jr == null) {",
+                   "    \t\t GLib.debug(\"Problem getting item\"); ",
+                   "    \t\t return;",
+                   "    \t }",
                    "",
+                   "\t\tjr.bind_property(\"icon\",",
+                   "                img, \"gicon\",",
+                   "               GLib.BindingFlags.SYNC_CREATE);",
                    "",
+                   "    \t//GLib.debug(\"change  %s to %s\", lbl.label, np.name);",
+                   "    \tlbl.label = jr.name; // for dir's we could hsow the sub path..",
+                   "    \tlbl.tooltip_markup = jr.path;",
+                   "    \t ",
+                   "        expand.set_hide_expander(  jr.xtype != \"Dir\" );",
+                   "     \t expand.set_list_row(lr);",
+                   "     ",
+                   "         \t ",
+                   "                 \t// bind image...",
+                   "}",
                    ""
                   ],
                   "setup" : [
                    "\t ",
                    "\texpand.set_indent_for_depth(true);",
                    "\texpand.set_indent_for_icon(true);",
-                   "\t ",
+                   "\tvar hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);",
+                   "\tvar icon = new Gtk.Image();",
+                   "\ticon.margin_end = 4;",
                    "\tvar lbl = new Gtk.Label(\"\");",
                    "\tlbl.use_markup = true;",
                    "\t",
                    " \tlbl.justify = Gtk.Justification.LEFT;",
                    " \tlbl.xalign = 0;",
                    "",
-                   " ",
-                   "\texpand.set_child(lbl);",
+                   " \thbox.append(icon);",
+                   "\thbox.append(lbl);",
+                   "\texpand.set_child(hbox);",
                    "\t((Gtk.ListItem)listitem).set_child(expand);",
                    "\t((Gtk.ListItem)listitem).activatable = false;",
                    "}",
          "   pe.el.application = _this.win.el.application;",
          "    pe.el.set_transient_for( _this.el );",
          " ",
-         "  ",
-         "    pe.selected.connect((pr) => {",
-         "     \t ",
-         "\t     _this.show(  pr, _this.new_window);",
-         "",
-         "    });",
-         "    ",
+         "    var cb = new Project.Callback();",
+         "    cb.call.connect((pr) => {",
+         "    \t_this.show(  pr , _this.new_window);",
+         "\t});",
          "      ",
-         "    pe.show();",
+         "    pe.show( cb);",
          "   ",
          "",
          "}"
         ]
        },
-       "xtype" : "Button"
+       "xtype" : "Button",
+       "| void onCreated" : [
+        "() {",
+        "\tvar pe =      EditProject.singleton();",
+        "",
+        "\t_this.show(  pe.result , _this.new_window);",
+        "}"
+       ]
       },
       {
        "$ xns" : "Gtk",
          "   if (_this.selectedProject == null) {",
          "\t   return;",
          "   }",
-         "\t_this.win.windowstate.projectPopoverShow(_this.el, _this.selectedProject);",
+         "\t_this.win.windowstate.projectPopoverShow(_this.el, _this.selectedProject, null);",
          " }"
         ]
        },
    "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));",
     "     Project.Project.loadIntoStore(this.projectmodel.el);",
     "    ",
     "    _this.projectselection.el.selected = Gtk.INVALID_LIST_POSITION; ",
     "\t_this.btn_delfile.el.hide();",
-    "\t",
+    " ",
     "  ",
     "}",
     ""
     " ",
     "\t",
     "\t this.el.show();",
-    "\t \tthis.load();",
+    " this.load();",
     "\tthis.selectProject(project);",
     "\tthis.onProjectSelected(project);   //?? twice?",
     "\t ",