示例#1
0
        protected override void OnActivated()
        {
            try {
                if (!item.IsValid)
                {
                    throw new ApplicationException("attempt to filter invalid item");
                }

                using (FilterRequest req = new FilterRequest(item.Current.DefaultVersionUri)) {
                    IFilter filter = BuildFilter();
                    if (filter.Convert(req))
                    {
                        // The filter did something so lets ve
                        EditTarget target = new EditTarget(item);

                        Gnome.Vfs.Result result = Gnome.Vfs.Result.Ok;
                        result = Gnome.Vfs.Xfer.XferUri(new Gnome.Vfs.Uri(req.Current.ToString()),
                                                        new Gnome.Vfs.Uri(target.Uri.ToString()),
                                                        Gnome.Vfs.XferOptions.Default,
                                                        Gnome.Vfs.XferErrorMode.Abort,
                                                        Gnome.Vfs.XferOverwriteMode.Replace,
                                                        delegate {
                            System.Console.WriteLine("progress");
                            return(1);
                        });

                        if (result == Gnome.Vfs.Result.Ok)
                        {
                            System.Console.WriteLine("Done modifying image");
                            target.Commit();
                        }
                        else
                        {
                            target.Delete();
                            throw new ApplicationException(String.Format(
                                                               "{0}: error moving to destination {1}",
                                                               this, target.ToString()));
                        }
                    }
                }
            } catch (Exception e) {
                Dialog d = new EditExceptionDialog(null, e, item.Current);
                d.Show();
                d.Run();
                d.Destroy();
            }
        }
示例#2
0
        protected override void OnActivated()
        {
            try {
                RotateOperation op = new RotateOperation(item.Current, direction);

                while (op.Step())
                {
                }

                item.Collection.MarkChanged(item.Index, FullInvalidate.Instance);
            } catch (Exception e) {
                Dialog d = new EditExceptionDialog(null, e, item.Current);
                d.Show();
                d.Run();
                d.Destroy();
            }
        }
示例#3
0
        private void Render()
        {
            double page_width, page_height;

            print_job.GetPageSize(out page_width, out page_height);
            Gnome.PrintContext ctx = print_job.Context;

            ArrayList exceptions = new ArrayList();

            foreach (Photo photo in photos)
            {
                Gdk.Pixbuf image = null;
                try {
                    image = FSpot.PhotoLoader.Load(photo);

                    if (image == null)
                    {
                        throw new System.Exception("Error loading picture");
                    }
                } catch (Exception e) {
                    exceptions.Add(e);
                    continue;
                }

                Gdk.Pixbuf flat = PixbufUtils.Flatten(image);
                if (flat != null)
                {
                    image.Dispose();
                    image = flat;
                }

                Gnome.Print.Beginpage(ctx, "F-Spot" + photo.DefaultVersionUri.ToString());

                bool   rotate = false;
                double width  = page_width;
                double height = page_height;
                if (image.Width > image.Height)
                {
                    rotate = true;
                    width  = page_height;
                    height = page_width;
                }

                double scale = System.Math.Min(width / image.Width,
                                               height / image.Height);

                Gnome.Print.Gsave(ctx);

                if (rotate)
                {
                    Gnome.Print.Rotate(ctx, 90);
                    Gnome.Print.Translate(ctx, 0, -page_width);
                }

                Gnome.Print.Translate(ctx,
                                      (width - image.Width * scale) / 2.0,
                                      (height - image.Height * scale) / 2.0);

                Gnome.Print.Scale(ctx, image.Width * scale, image.Height * scale);
                Gnome.Print.Pixbuf(ctx, image);
                Gnome.Print.Grestore(ctx);

                Gnome.Print.Showpage(ctx);
                image.Dispose();
            }

            print_job.Close();

            if (exceptions.Count != 0)
            {
                //FIXME string freeze the message here is not
                //really appropriate to the problem.
                Dialog md = new EditExceptionDialog(print_dialog,
                                                    (Exception [])exceptions.ToArray(typeof(Exception)));
                md.Run();
                md.Destroy();
            }
        }
		protected override void OnActivated ()
		{
			try {
				RotateOperation op = new RotateOperation (item.Current, direction);
				
				while (op.Step ());
				
				item.Collection.MarkChanged (item.Index);
			} catch (Exception e) {
				Dialog d = new EditExceptionDialog (null, e, item.Current);
				d.Show ();
				d.Run ();
				d.Destroy ();
			}
			   
		}
		protected override void OnActivated ()
		{
			try {
				if (!item.IsValid)
					throw new ApplicationException ("attempt to filter invalid item");
				
				using (FilterRequest req = new FilterRequest (item.Current.DefaultVersionUri)) {
					IFilter filter = BuildFilter ();
					if (filter.Convert (req)) {
						// The filter did something so lets ve
						EditTarget target = new EditTarget (item);
					
						Gnome.Vfs.Result result = Gnome.Vfs.Result.Ok;
						result = Gnome.Vfs.Xfer.XferUri (new Gnome.Vfs.Uri (req.Current.ToString ()),
										 new Gnome.Vfs.Uri (target.Uri.ToString ()),
										 Gnome.Vfs.XferOptions.Default,
										 Gnome.Vfs.XferErrorMode.Abort, 
										 Gnome.Vfs.XferOverwriteMode.Replace, 
										 delegate {
											 System.Console.WriteLine ("progress");
											 return 1;
										 });
						
						if (result == Gnome.Vfs.Result.Ok) {
							System.Console.WriteLine ("Done modifying image");
							target.Commit ();
						} else {
							target.Delete ();
							throw new ApplicationException (String.Format (
												       "{0}: error moving to destination {1}",
												       this, target.ToString ()));
						}
					}
				}
			} catch (Exception e) {
				Dialog d = new EditExceptionDialog (null, e, item.Current);
				d.Show ();
				d.Run ();
				d.Destroy ();
			} 
		}
	public void HandleOpenWith (object sender, Gnome.Vfs.MimeApplication mime_application)
	{
		Photo[] selected = SelectedPhotos ();

		if (selected == null || selected.Length < 1)
			return;

		string header = Catalog.GetPluralString ("Create New Version?", "Create New Versions?", selected.Length); 
		string msg = String.Format (Catalog.GetPluralString (
				"Before launching {1}, should F-Spot create a new version of the selected photo to preserve the original?",
				"Before launching {1}, should F-Spot create new versions of the selected photos to preserve the originals?", selected.Length),
				selected.Length, mime_application.Name);

		// FIXME add cancel button? add help button?
		HigMessageDialog hmd = new HigMessageDialog(GetToplevel (sender), DialogFlags.DestroyWithParent, 
							    MessageType.Question, Gtk.ButtonsType.None,
							    header, msg);

		hmd.AddButton (Gtk.Stock.No, Gtk.ResponseType.No, false);
		//hmd.AddButton (Gtk.Stock.Cancel, Gtk.ResponseType.Cancel, false);
		hmd.AddButton (Gtk.Stock.Yes, Gtk.ResponseType.Yes, true);

		Gtk.ResponseType response = Gtk.ResponseType.Cancel;

		try {
			response = (Gtk.ResponseType) hmd.Run();
		} finally {
			hmd.Destroy ();
		}

		if (response == Gtk.ResponseType.Cancel)
			return;

		bool create_new_versions = (response == Gtk.ResponseType.Yes);

		ArrayList errors = new ArrayList ();
		GLib.List uri_list = new GLib.List (typeof (string));
		foreach (Photo photo in selected) {
			try {
				if (create_new_versions) {
					uint version = photo.CreateNamedVersion (mime_application.Name, photo.DefaultVersionId, true);
					photo.DefaultVersionId = version;
				}
				query.MarkChanged (query.IndexOf (photo));
			} catch (Exception e) {
				errors.Add (new EditException (photo, e));
			}

			uri_list.Append (photo.DefaultVersionUri.ToString ());
		}

		// FIXME need to clean up the error dialog here.
		if (errors.Count > 0) {
			Dialog md = new EditExceptionDialog (GetToplevel (sender), errors.ToArray (typeof (EditException)) as EditException []);
			md.Run ();
			md.Destroy ();
		}

		if (create_new_versions) {
			db.Photos.Commit (selected, new DbItemEventArgs (selected));
		}

		mime_application.Launch (uri_list);
	}
		private void Render ()
		{
			double page_width, page_height;
			print_job.GetPageSize (out page_width, out page_height);
			Gnome.PrintContext ctx = print_job.Context;

			ArrayList exceptions = new ArrayList ();

			foreach (Photo photo in photos) {
				Gdk.Pixbuf image =  null;
				try {
					image = FSpot.PhotoLoader.Load (photo);

					if (image == null)
						throw new System.Exception ("Error loading picture");

				} catch (Exception  e) {
					exceptions.Add (e);
					continue;
				}

				Gdk.Pixbuf flat = PixbufUtils.Flatten (image);
				if (flat != null) {
					image.Dispose ();
					image = flat;
				}

				Gnome.Print.Beginpage (ctx, "F-Spot" + photo.DefaultVersionUri.ToString ());				

				bool rotate = false;
				double width = page_width;
				double height = page_height;
				if (image.Width > image.Height) {
					rotate = true;
					width = page_height;
					height = page_width;
				}

				double scale = System.Math.Min (width / image.Width, 
								height / image.Height);

				Gnome.Print.Gsave (ctx);

				if (rotate) {
					Gnome.Print.Rotate (ctx, 90);
					Gnome.Print.Translate (ctx, 0, -page_width);
				}
				
				Gnome.Print.Translate (ctx,
						       (width - image.Width * scale) / 2.0,
						       (height - image.Height * scale) / 2.0);
				
				Gnome.Print.Scale (ctx, image.Width * scale, image.Height * scale);
				Gnome.Print.Pixbuf (ctx, image);
				Gnome.Print.Grestore (ctx);

				Gnome.Print.Showpage (ctx);
				image.Dispose ();
			}
			
			print_job.Close ();

			if (exceptions.Count != 0) {
				//FIXME string freeze the message here is not
				//really appropriate to the problem.
				Dialog md = new EditExceptionDialog (print_dialog, 
								     (Exception [])exceptions.ToArray (typeof (Exception)));
				md.Run ();
				md.Destroy ();
			}
				
		}