public void HandleThumbnailLoaded (PixbufLoader loader, Uri uri, int order, Gdk.Pixbuf result)
		{
			string thumb_path = ThumbnailGenerator.ThumbnailPath (uri);
			
			if (result != null)
				Reload (thumb_path);
		}
		public void HandleThumbnailLoaded (PixbufLoader loader, string path, int order, Gdk.Pixbuf result)
		{
			string thumb_path = ThumbnailGenerator.ThumbnailPath (new System.Uri (path));
			
			if (result != null)
				Reload (thumb_path);
		}
Exemple #3
0
        public void HandleThumbnailLoaded(PixbufLoader loader, string path, int order, Gdk.Pixbuf result)
        {
            string thumb_path = ThumbnailGenerator.ThumbnailPath(new System.Uri(path));

            if (result != null)
            {
                Reload(thumb_path);
            }
        }
        public void HandleThumbnailLoaded(PixbufLoader loader, Uri uri, int order, Gdk.Pixbuf result)
        {
            string thumb_path = ThumbnailGenerator.ThumbnailPath(uri);

            if (result != null)
            {
                Reload(thumb_path);
            }
        }
        void HandlePixbufLoaded(PixbufLoader pl, Uri uri, int order, Pixbuf p)
        {
            if (!thumb_cache.Contains(FSpot.ThumbnailGenerator.ThumbnailPath(uri)))
            {
                return;
            }

            //FIXME use QueueDrawArea
            //FIXME only invalidate if displayed
            QueueDraw();
        }
Exemple #6
0
 public void HandleDestroyed(object sender, System.EventArgs args)
 {
     Log.Information("Exiting");
     toplevels.Remove(sender);
     if (toplevels.Count == 0)
     {
         Banshee.Kernel.Scheduler.Dispose();
         Core.Database.Dispose();
         PixbufLoader.Cleanup();
         Gtk.Application.Quit();
         System.Environment.Exit(0);
     }
     if (organizer != null && organizer.Window == sender)
     {
         organizer = null;
     }
 }
Exemple #7
0
        public static Pixbuf GetIconFromFile(string path)
        {
            try
            {
                string[] mimetypes =
                    LaunchProcess("gio", $"info -a standard::icon \"{path}\"")
                    .Split(new string[] { ": " }, StringSplitOptions.None)[3]
                    .Split(new string[] { ", " }, StringSplitOptions.None);
                mimetypes[0] = mimetypes[0].TrimStart(' ');

                string theme = LaunchProcess("gsettings", "get org.gnome.desktop.interface icon-theme");
                theme = theme.TrimEnd('\n').Trim('\'');

                foreach (string s in mimetypes)
                {
                    string file = string.Format("/usr/share/icons/{0}/mimetypes/16/{1}.svg", theme, s);
                    if (File.Exists(file))
                    {
                        var pixbufld = new PixbufLoader();
                        pixbufld.Write(Encoding.UTF8.GetBytes(File.ReadAllText(file)));
                        pixbufld.Close();
                        return(pixbufld.Pixbuf);
                    }

                    file = string.Format("/usr/share/icons/{0}/16x16/mimetypes/{1}.svg", theme, s);
                    if (File.Exists(file))
                    {
                        var pixbufld = new PixbufLoader();
                        pixbufld.Write(Encoding.UTF8.GetBytes(File.ReadAllText(file)));
                        pixbufld.Close();
                        return(pixbufld.Pixbuf);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine($"Unable to retrieve the icon of {path}: {e}");
            }

            return(IconLoader.LoadIcon(Program.WinInstance, "gtk-file", IconSize.Menu));
        }
Exemple #8
0
        public static Pixbuf LoadThumbnail(SafeUri uri, ThumbnailSize size, PixbufLoader loader)
        {
            var thumb_uri = ThumbUri(uri, size);
            var pixbuf    = LoadFromUri(thumb_uri);

            if (!IsValid(uri, pixbuf))
            {
                Log.DebugFormat("Invalid thumbnail, reloading: {0}", uri);
                if (pixbuf != null)
                {
                    pixbuf.Dispose();
                }

                if (loader == null)
                {
                    return(null);
                }

                pixbuf = CreateFrom(uri, thumb_uri, size, loader);
            }
            return(pixbuf);
        }
Exemple #9
0
        private static Pixbuf CreateFrom(SafeUri uri, SafeUri thumb_uri, ThumbnailSize size, PixbufLoader loader)
        {
            var    pixels = size == ThumbnailSize.Normal ? 128 : 256;
            Pixbuf pixbuf;

            try {
                pixbuf = loader(uri);
            } catch (Exception e) {
                Log.DebugFormat("Failed loading image for thumbnailing: {0}", uri);
                Log.DebugException(e);
                return(null);
            }
            double scale_x  = (double)pixbuf.Width / pixels;
            double scale_y  = (double)pixbuf.Height / pixels;
            double scale    = Math.Max(1.0, Math.Max(scale_x, scale_y));
            int    target_x = (int)(pixbuf.Width / scale);
            int    target_y = (int)(pixbuf.Height / scale);

            // FIXME, This isn't correct, but for now it ensures that the minimum
            //        value is 1 so that pixbuf.ScaleSimple doesn't return null
            //        Seems to only happen in rare(?) cases
            if (target_x == 0)
            {
                target_x = 1;
            }
            if (target_y == 0)
            {
                target_y = 1;
            }
            var thumb_pixbuf = pixbuf.ScaleSimple(target_x, target_y, InterpType.Bilinear);

            pixbuf.Dispose();

            var file  = GLib.FileFactory.NewForUri(uri);
            var info  = file.QueryInfo("time::modified", GLib.FileQueryInfoFlags.None, null);
            var mtime = info.GetAttributeULong("time::modified").ToString();

            thumb_pixbuf.Savev(thumb_uri.LocalPath, "png",
                               new string [] { ThumbUriOpt, ThumbMTimeOpt, null },
                               new string [] { uri, mtime });

            return(thumb_pixbuf);
        }