Example #1
0
        public static void Save(Gdk.Pixbuf image, Uri dest)
        {
            string uri = UriUtils.UriToStringEscaped(dest);

            System.DateTime mtime = DateTime.Now;

            // Use Gnome.Vfs
            try {
                Gnome.Vfs.FileInfo vfs = new Gnome.Vfs.FileInfo(uri);
                mtime = vfs.Mtime;

                PixbufUtils.SetOption(image, ThumbUri, uri);
                PixbufUtils.SetOption(image, ThumbMTime,
                                      ((uint)GLib.Marshaller.DateTimeTotime_t(mtime)).ToString());
            } catch (System.Exception e) {
                Console.WriteLine(e);
            }

            //System.Console.WriteLine ("saving uri \"{0}\" mtime \"{1}\"",
            //			  image.GetOption ("tEXt::Thumb::URI"),
            //			  image.GetOption ("tEXt::Thumb::MTime"));

            string large_path = ThumbnailPath(uri);

            try {
                ThumbnailCache.Default.RemoveThumbnailForPath(large_path);
            } finally {
                factory.SaveThumbnail(image, uri, mtime);
            }
        }
Example #2
0
        public static bool ThumbnailIsValid(Gdk.Pixbuf thumbnail, System.Uri uri)
        {
            bool valid = false;

            try {
                Gnome.Vfs.FileInfo vfs   = new Gnome.Vfs.FileInfo(uri.ToString());
                DateTime           mtime = vfs.Mtime;
                valid = Gnome.Thumbnail.IsValid(thumbnail, UriUtils.UriToStringEscaped(uri), mtime);
            } catch (System.IO.FileNotFoundException) {
                // If the original file is not on disk, the thumbnail is as valid as it's going to get
                valid = true;
            } catch (System.Exception e) {
                System.Console.WriteLine(e);
                valid = false;
            }

            return(valid);
        }
Example #3
0
        public static string ThumbnailPath(System.Uri uri)
        {
            string large_path = Gnome.Thumbnail.PathForUri(UriUtils.UriToStringEscaped(uri), Gnome.ThumbnailSize.Large);

            return(large_path);
        }