Пример #1
0
    public void DeleteVersion(uint version_id, bool remove_original)
    {
        if (version_id == OriginalVersionId && !remove_original)
        {
            throw new Exception("Cannot delete original version");
        }

        string path = GetVersionPath(version_id);

        if (File.Exists(path))
        {
            File.Delete(path);
        }

        try {
            string thumb_path = ThumbnailGenerator.ThumbnailPath(path);
            File.Delete(thumb_path);
        } catch (System.Exception) {
            //ignore an error here we don't really care.
        }

        PhotoStore.DeleteThumbnail(path);

        version_names.Remove(version_id);

        do
        {
            version_id--;
            if (version_names.Contains(version_id))
            {
                DefaultVersionId = version_id;
                break;
            }
        } while (version_id > OriginalVersionId);
    }
Пример #2
0
        private void HandleThumbnailIconViewButtonPressEvent(object sender, Gtk.ButtonPressEventArgs args)
        {
            int old_item = current_item;

            current_item = thumbnail_iconview.CellAtPosition((int)args.Event.X, (int)args.Event.Y, false);

            if (current_item < 0 || current_item >= items.Length)
            {
                current_item = old_item;
                return;
            }

            captions [old_item] = caption_textview.Buffer.Text;

            string caption = captions [current_item];

            if (caption == null)
            {
                captions [current_item] = caption = "";
            }
            caption_textview.Buffer.Text = caption;

            tag_treeview.Model = new TagStore(account.Facebook, tags [current_item], friends);

            IBrowsableItem item           = items [current_item];
            string         thumbnail_path = ThumbnailGenerator.ThumbnailPath(item.DefaultVersionUri);

            if (tag_image_eventbox.Children.Length > 0)
            {
                tag_image_eventbox.Remove(tag_image);
                tag_image.Destroy();
            }

            using (ImageFile image = new ImageFile(thumbnail_path)) {
                Gdk.Pixbuf data = image.Load();
                data             = PixbufUtils.ScaleToMaxSize(data, 400, 400);
                tag_image_height = data.Height;
                tag_image_width  = data.Width;
                tag_image        = new Gtk.Image(data);
                tag_image_eventbox.Add(tag_image);
                tag_image_eventbox.ShowAll();
            }
        }
Пример #3
0
 public static void MoveThumbnail(string old_path, string new_path)
 {
     File.Move(ThumbnailGenerator.ThumbnailPath(UriList.PathToFileUri(old_path)),
               ThumbnailGenerator.ThumbnailPath(UriList.PathToFileUri(new_path)));
 }
Пример #4
0
        private void StartServer()
        {
            Console.WriteLine("Starting DPAP server");

            DPAP.Database database = new DPAP.Database("DPAP");

            DPAP.Server server = new Server(System.Environment.UserName.ToString() + " f-spot photos");
            server.Port = 8770;
            server.AuthenticationMethod = AuthenticationMethod.None;
            int collision_count = 0;

            server.Collision += delegate {
                server.Name = System.Environment.UserName.ToString() + " f-spot photos" + "[" + ++collision_count + "]";
            };


            //FSpot.Photo photo = (FSpot.Photo) Core.Database.Photos.Get (1);

            try {
                Album a = new Album("test album");
                Tag   t = Core.Database.Tags.GetTagByName("Shared items");

                Tag []         tags   = { t };
                FSpot.Photo [] photos = Core.Database.Photos.Query(tags);
                int            i      = 0;

                foreach (FSpot.Photo photo in photos)
                {
                    string     thumbnail_path = ThumbnailGenerator.ThumbnailPath(photo.DefaultVersionUri);
                    FileInfo   f = new FileInfo(thumbnail_path);
                    DPAP.Photo p = new DPAP.Photo();

                    p.FileName  = photo.Name;
                    p.Thumbnail = thumbnail_path;
                    p.ThumbSize = (int)f.Length;
                    p.Path      = photo.DefaultVersionUri.ToString().Substring(7);
                    f           = new FileInfo(photo.DefaultVersionUri.ToString().Substring(7));
                    if (!f.Exists)
                    {
                        continue;
                    }

                    //if (++i > 2) break;
                    Console.WriteLine("Found photo " + p.Path + ", thumb " + thumbnail_path);
                    p.Title  = f.Name;
                    p.Size   = (int)f.Length;
                    p.Format = "JPEG";
                    database.AddPhoto(p);
                    a.AddPhoto(p);
                }

                database.AddAlbum(a);
                Console.WriteLine("Album count is now " + database.Albums.Count);
                server.AddDatabase(database);

                //server.GetServerInfoNode ();
                try {
                    server.Start();
                } catch (System.Net.Sockets.SocketException) {
                    Console.WriteLine("Server socket exception!");
                    server.Port = 0;
                    server.Start();
                }

                //DaapPlugin.ServerEnabledSchema.Set (true);

                //  if(!initial_db_committed) {
                server.Commit();

                //      initial_db_committed = true;
                //  }
            } catch (Exception e) {
                Console.WriteLine("Failed starting dpap server \n{0}", e);
            }
        }
Пример #5
0
 public static void MoveThumbnail(string old_path, string new_path)
 {
     System.IO.File.Move(ThumbnailGenerator.ThumbnailPath(UriUtils.PathToFileUri(old_path)),
                         ThumbnailGenerator.ThumbnailPath(UriUtils.PathToFileUri(new_path)));
 }