JsRender/Gtk.vala.c
[app.Builder.js] / Builder4 / ClutterFiles.bjs
index 935b823..3efe855 100644 (file)
@@ -18,6 +18,7 @@
             "xtype" : "ScrollActor",
             "$ reactive" : true,
             "|  void loadProject" : "(Project.Project pr) {\n    // list all the files, and create new Xcls_fileitem for each one.\n    \n    // LEAK --- we should unref all the chilren...\n    this.filelayout.el.y = 0;\n    this.clearFiles();\n    \n    print(\"clutter files - load project: \" + pr.name +\"\\n\");\n    // should unref.. them hopefully.\n    this.fileitems = new Gee.ArrayList<Xcls_fileitem>();\n\n    \n\n    var fiter = pr.sortedFiles().list_iterator();\n    while (fiter.next()) {\n        var a = new Xcls_fileitem(this,fiter.get());\n        this.fileitems.add(a);\n\n//        a.ref();\n        print(\"add to clutter file view: \" + fiter.get().name + \"\\n\");\n        this.filelayout.el.add_child(a.el);\n    }\n    \n   \n    \n    this.el.show_all();\n}\n",
+            "# Gdk.Pixbuf missing_thumb_pixbuf" : "null",
             "@ void open" : "(JsRender.JsRender file)",
             "$ xns" : "Clutter",
             "|  void set_size" : "(float w, float h) \n{\n     if (this.el == null) {\n        print(\"object not ready yet?\");\n        return;\n    }\n   _this.filelayout_manager.el.max_column_width = w - 150;\n   this.el.set_size(this.el.get_stage().width-150,\n                        this.el.get_stage().height);\n            this.el.set_position(100,50);\n}\n",
@@ -67,7 +68,7 @@
                                     "$ margin_top" : 5,
                                     "id" : "+image",
                                     "* args" : "JsRender.JsRender file",
-                                    "* init" : "{\n    Gdk.Pixbuf pixbuf;\n    var fname = file.getIconFileName(false);\n\n    if (FileUtils.test(fname, FileTest.EXISTS)) {\n        pixbuf = new Gdk.Pixbuf.from_file(fname);\n    } else {\n        var     icon_theme = Gtk.IconTheme.get_default ();\n       pixbuf = icon_theme.load_icon (\"package-x-generic\", 92, 0);\n\n    }\n\n    var img = new Clutter.Image();\n    img.set_data(pixbuf.get_pixels(),   \n                        pixbuf.has_alpha \n                          ? Cogl.PixelFormat.RGBA_8888\n                          : Cogl.PixelFormat.RGB_888,\n                        pixbuf.get_width (),\n            pixbuf.get_height (),\n                        pixbuf.get_rowstride ()\n    );\n    this.el.set_content(img);\n     // should probably do smarter scaling...\n    \n    \n    this.el.set_size(90, 70);\n}\n",
+                                    "* init" : "{\n    Gdk.Pixbuf pixbuf;\n    var fname = file.getIconFileName(false);\n\n    if (FileUtils.test(fname, FileTest.EXISTS)) {\n        pixbuf = new Gdk.Pixbuf.from_file(fname);\n    } else {\n        if (_this.missing_thumb_pixbuf == null) {\n                var     icon_theme = Gtk.IconTheme.get_default ();\n                _this.missing_thumb_pixbuf = icon_theme.load_icon (\"package-x-generic\", 92, 0);\n                _this.missing_thumb_pixbuf.ref();\n            }\n            pixbuf = _this.missing_thumb_pixbuf;\n\n    }\n\n    var img = new Clutter.Image();\n    img.set_data(pixbuf.get_pixels(),   \n                        pixbuf.has_alpha \n                          ? Cogl.PixelFormat.RGBA_8888\n                          : Cogl.PixelFormat.RGB_888,\n                        pixbuf.get_width (),\n            pixbuf.get_height (),\n                        pixbuf.get_rowstride ()\n    );\n    this.el.set_content(img);\n     // should probably do smarter scaling...\n    \n    \n    this.el.set_size(90, 70);\n}\n",
                                     "$ x_expand" : true,
                                     "* pack" : "add_child",
                                     "xtype" : "Actor",