src/Builder4/PopoverFiles.bjs
authorAlan <alan@roojs.com>
Fri, 2 Sep 2022 04:26:56 +0000 (12:26 +0800)
committerAlan <alan@roojs.com>
Fri, 2 Sep 2022 04:26:56 +0000 (12:26 +0800)
src/Builder4/PopoverFiles.vala

src/Builder4/PopoverFiles.bjs
src/Builder4/PopoverFiles.vala

index bbc3823..61843c5 100644 (file)
     "}",
     ""
    ],
+   "| void loadIconView" : [
+    "() {",
+    " \tGdk.Pixbuf pixbuf = null;",
+    "  \t Gdk.Pixbuf bigpixbuf = null;",
+    "\t Gtk.TreeIter iter;",
+    "     var m = this.iconmodel.el;",
+    "     m.clear();",
+    " ",
+    "    var fiter = project.sortedFiles().list_iterator();",
+    "    while (fiter.next()) {",
+    "        m.append(out iter);",
+    "        var file = fiter.get();",
+    "        m.set(iter,   0,file ); // zero contains the file reference",
+    "        m.set(iter,   1,file.nickType() + \"\\n\" + file.nickName()); // marked up title?",
+    "        m.set(iter,   2,file.nickType() ); // file type?",
+    "        ",
+    "        ",
+    "        var fname = file.getIconFileName(false);",
+    "        try {",
+    "\t\t    if (FileUtils.test(fname, FileTest.EXISTS)) {",
+    "\t\t        var npixbuf = new Gdk.Pixbuf.from_file(fname);",
+    "\t\t        pixbuf = npixbuf.scale_simple(92, (int) (npixbuf.height * 92.0 /npixbuf.width * 1.0 )",
+    "\t\t\t\t    , Gdk.InterpType.NEAREST) ;",
+    "\t\t\t\tbigpixbuf = npixbuf.scale_simple(368, (int) (npixbuf.height * 368.0 /npixbuf.width * 1.0 )",
+    "\t\t\t\t    , Gdk.InterpType.NEAREST) ;",
+    "\t\t\t\t",
+    "\t\t    } ",
+    "\t\t} catch (Error e) {",
+    "\t\t    // noop",
+    "\t\t",
+    "\t\t}",
+    "        if (pixbuf == null) {",
+    "        ",
+    "\t\t    try {",
+    "\t\t        if (_this.missing_thumb_pixbuf == null) {",
+    "\t\t            var icon_theme = Gtk.IconTheme.get_default ();",
+    "\t\t            _this.missing_thumb_pixbuf = icon_theme.load_icon (\"package-x-generic\", 92, 0);",
+    "\t\t            _this.missing_thumb_pixbuf.ref();",
+    "\t\t        }",
+    "\t\t        pixbuf = _this.missing_thumb_pixbuf;",
+    "\t\t        bigpixbuf = _this.missing_thumb_pixbuf;",
+    "",
+    "\t\t    } catch (Error e) {",
+    "\t\t        // noop?",
+    "\t\t    }",
+    "\t\t}",
+    "\t\t",
+    "\t\t",
+    "\t\t",
+    "        m.set(iter,   3,pixbuf);",
+    "        m.set(iter,   4,bigpixbuf);",
+    "      ",
+    "        // this needs to add to the iconview?",
+    "        ",
+    "        //var a = new Xcls_fileitem(this,fiter.get());",
+    "        //this.fileitems.add(a);",
+    "",
+    "        //this.filelayout.el.add_child(a.el);",
+    "    }",
+    "}"
+   ],
    "| void onProjectSelected" : [
     "(Project.Project project) ",
     "{",
     "    ",
     "    // file items contains a reference until we reload ...",
     "  \t Gdk.Pixbuf pixbuf = null;",
-    "  \tGdk.Pixbuf bigpixbuf = null;",
+    "  \t Gdk.Pixbuf bigpixbuf = null;",
     "\t Gtk.TreeIter iter;",
     "     var m = this.iconmodel.el;",
     "     m.clear();",
index 5d54bc6..4104b16 100644 (file)
@@ -84,7 +84,7 @@ public class Xcls_PopoverFiles : Object
         
         // file items contains a reference until we reload ...
         Gdk.Pixbuf pixbuf = null;
-       Gdk.Pixbuf bigpixbuf = null;
+        Gdk.Pixbuf bigpixbuf = null;
         Gtk.TreeIter iter;
          var m = this.iconmodel.el;
          m.clear();
@@ -291,6 +291,65 @@ public class Xcls_PopoverFiles : Object
        this.win = win;
         
     }
+    public void loadIconView () {
+       Gdk.Pixbuf pixbuf = null;
+        Gdk.Pixbuf bigpixbuf = null;
+        Gtk.TreeIter iter;
+         var m = this.iconmodel.el;
+         m.clear();
+     
+        var fiter = project.sortedFiles().list_iterator();
+        while (fiter.next()) {
+            m.append(out iter);
+            var file = fiter.get();
+            m.set(iter,   0,file ); // zero contains the file reference
+            m.set(iter,   1,file.nickType() + "\n" + file.nickName()); // marked up title?
+            m.set(iter,   2,file.nickType() ); // file type?
+            
+            
+            var fname = file.getIconFileName(false);
+            try {
+                   if (FileUtils.test(fname, FileTest.EXISTS)) {
+                       var npixbuf = new Gdk.Pixbuf.from_file(fname);
+                       pixbuf = npixbuf.scale_simple(92, (int) (npixbuf.height * 92.0 /npixbuf.width * 1.0 )
+                                   , Gdk.InterpType.NEAREST) ;
+                               bigpixbuf = npixbuf.scale_simple(368, (int) (npixbuf.height * 368.0 /npixbuf.width * 1.0 )
+                                   , Gdk.InterpType.NEAREST) ;
+                               
+                   } 
+               } catch (Error e) {
+                   // noop
+               
+               }
+            if (pixbuf == null) {
+            
+                   try {
+                       if (_this.missing_thumb_pixbuf == null) {
+                           var icon_theme = Gtk.IconTheme.get_default ();
+                           _this.missing_thumb_pixbuf = icon_theme.load_icon ("package-x-generic", 92, 0);
+                           _this.missing_thumb_pixbuf.ref();
+                       }
+                       pixbuf = _this.missing_thumb_pixbuf;
+                       bigpixbuf = _this.missing_thumb_pixbuf;
+    
+                   } catch (Error e) {
+                       // noop?
+                   }
+               }
+               
+               
+               
+            m.set(iter,   3,pixbuf);
+            m.set(iter,   4,bigpixbuf);
+          
+            // this needs to add to the iconview?
+            
+            //var a = new Xcls_fileitem(this,fiter.get());
+            //this.fileitems.add(a);
+    
+            //this.filelayout.el.add_child(a.el);
+        }
+    }
     public class Xcls_Box2 : Object
     {
         public Gtk.Box el;