Proposed patch for slideshow keyboard controls



 Hi all,

Here's a proposed patch that adds rudimentary slideshow controls - space pauses and resumes, and the left and right arrows show the previous and next images.   I had a bit of trouble getting the pause functionality to interact properly with the image transitions -- the best solution I ended up with was to automatically skip to the next image if  you pause during a transition.

I might try to add a mechanism to properly resume the transition - but I think this patch is useful as is...   If people think this looks ok, I'll try to find a bug to attach it to, or create a new one.

Warren

diff -ur clean/f-spot-0.1.11/src/SlideView.cs f-spot-0.1.11/src/SlideView.cs
--- clean/f-spot-0.1.11/src/SlideView.cs	2006-03-01 19:19:39.000000000 -0500
+++ f-spot-0.1.11/src/SlideView.cs	2006-03-27 00:39:50.000000000 -0500
@@ -64,6 +64,7 @@
 		private Delay hide;
 		private Gdk.Cursor busy;
 		private Gdk.Cursor none;
+		private bool isPlaying;
 		
 		public FullSlide (Gtk.Window parent, IBrowsableItem [] items) : base ("Slideshow")
 		{
@@ -125,12 +126,42 @@
 			
 			slideview.Play ();
 			hide.Start ();
+			isPlaying = true;
 		}
 		
 		[GLib.ConnectBefore]
 		private void HandleSlideViewKeyPressEvent (object sender, KeyPressEventArgs args)
 		{
-			this.Destroy ();
+					
+			switch(args.Event.Key) {
+			case Gdk.Key.Escape:	
+				this.Destroy ();
+				break;
+				
+			case Gdk.Key.space:
+			
+				if (isPlaying) {
+					slideview.PauseOnNext();
+					isPlaying = false;
+				} else {
+					slideview.Resume();
+					isPlaying = true;
+				}
+				break;
+			
+			case Gdk.Key.Left:
+				slideview.Back();
+				break;
+			
+			case Gdk.Key.Right:
+				slideview.Forward();
+				break;
+				
+			default:
+				this.Destroy();
+				break;
+			}
+			
 			args.RetVal = true;
 		}
 
@@ -218,6 +249,20 @@
 			StopFlipTimer ();
 		}
 		
+		public void PauseOnNext () 
+		{
+			if (transition_timer != 0) {
+				ShowNext();
+			}
+			StopTranstionTimer ();
+			StopFlipTimer ();
+		}
+
+		public void Resume () 
+		{
+			Play();
+		}
+			
 		public void Stop ()
 		{
 			StopTweenIdle ();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]