f-spot r4310 - in trunk: . src



Author: sdelcroix
Date: Wed Sep  3 11:07:07 2008
New Revision: 4310
URL: http://svn.gnome.org/viewvc/f-spot?rev=4310&view=rev

Log:
2008-09-03  Stephane Delcroix  <sdelcroix novell com>

	* src/FullScreenView.cs:
	* src/PhotoImageView.cs: new vim-like shortcuts for moving
	in a zoomed-in image. Patch from Anton Keks.


Modified:
   trunk/ChangeLog
   trunk/src/FullScreenView.cs
   trunk/src/PhotoImageView.cs

Modified: trunk/src/FullScreenView.cs
==============================================================================
--- trunk/src/FullScreenView.cs	(original)
+++ trunk/src/FullScreenView.cs	Wed Sep  3 11:07:07 2008
@@ -308,21 +308,37 @@
 
 		protected override bool OnKeyPressEvent (Gdk.EventKey key)
 		{
+			bool allow_quit = true;
+			
 			switch (key.Key) {
-				case Gdk.Key.Up:
-				case Gdk.Key.Left:
-				case Gdk.Key.KP_Up:
-				case Gdk.Key.KP_Left:
-				case Gdk.Key.Page_Up:
-				case Gdk.Key.Down:
-				case Gdk.Key.Right:
-				case Gdk.Key.KP_Down:
-				case Gdk.Key.KP_Right:
-				case Gdk.Key.Page_Down:
-					break;
-				default:
-					controls.Visibility = ControlOverlay.VisibilityType.Partial;
-					break;
+			// do not show controls on moving/zooming and modifier keys
+			case Gdk.Key.Up:
+			case Gdk.Key.Left:
+			case Gdk.Key.KP_Up:
+			case Gdk.Key.KP_Left:
+			case Gdk.Key.Page_Up:
+			case Gdk.Key.Down:
+			case Gdk.Key.Right:
+			case Gdk.Key.KP_Down:
+			case Gdk.Key.KP_Right:
+			case Gdk.Key.Page_Down:
+			case Gdk.Key.plus:
+			case Gdk.Key.minus:
+			case Gdk.Key.equal:
+			case Gdk.Key.KP_Add:
+			case Gdk.Key.KP_Subtract:
+			case Gdk.Key.Key_1:
+			case Gdk.Key.Key_0:
+			case Gdk.Key.Shift_L:
+			case Gdk.Key.Shift_R:
+			case Gdk.Key.Control_L:
+			case Gdk.Key.Control_R:
+				// do not quit on modifier keys as well - wait for following keystrokes
+				allow_quit = false;
+				break;
+			default:
+				controls.Visibility = ControlOverlay.VisibilityType.Partial;
+				break;
 			}
 
 			if (key == null) {
@@ -334,9 +350,9 @@
 				System.Console.WriteLine ("view == null", key);
 				return false;
 			}
-
+			
 			bool retval = base.OnKeyPressEvent (key);
-			if (!retval)
+			if (allow_quit && !retval)
 				Quit ();
 			else 
 				view.Fit = false;

Modified: trunk/src/PhotoImageView.cs
==============================================================================
--- trunk/src/PhotoImageView.cs	(original)
+++ trunk/src/PhotoImageView.cs	Wed Sep  3 11:07:07 2008
@@ -430,48 +430,84 @@
 			// for any of the default handlers.
 			args.RetVal = true;
 		
-			// Check for KeyPad arrow keys, which scroll the window when zoomed in
-			// but should go to the next/previous photo when not zoomed (no scrollbars)
-			if (this.Fit) {
-				switch (args.Event.Key) {
+			// Scroll if image is zoomed in (scrollbars are visible)
+			Gtk.ScrolledWindow scrolled = this.Parent as Gtk.ScrolledWindow;
+			if (scrolled != null && !this.Fit) {
+				Gtk.Adjustment vadj = scrolled.Vadjustment;
+				Gtk.Adjustment hadj = scrolled.Hadjustment;
+				switch (args.Event.Key) {					
 				case Gdk.Key.Up:
-				case Gdk.Key.Left:
 				case Gdk.Key.KP_Up:
+				case Gdk.Key.j:
+					vadj.Value -= vadj.StepIncrement;
+					if (vadj.Value < vadj.Lower)
+						vadj.Value = vadj.Lower;
+					return;
+				case Gdk.Key.Left:
 				case Gdk.Key.KP_Left:
-					this.Item.MovePrevious ();
+				case Gdk.Key.h:
+					hadj.Value -= hadj.StepIncrement;
+					if (hadj.Value < hadj.Lower)
+						hadj.Value = hadj.Lower;
 					return;
 				case Gdk.Key.Down:
-				case Gdk.Key.Right:
 				case Gdk.Key.KP_Down:
+				case Gdk.Key.k:
+					vadj.Value += vadj.StepIncrement;
+					if (vadj.Value > vadj.Upper - vadj.PageSize)
+						vadj.Value = vadj.Upper - vadj.PageSize;
+					return;
+				case Gdk.Key.Right:
 				case Gdk.Key.KP_Right:
-					this.Item.MoveNext ();
+				case Gdk.Key.l:
+					hadj.Value += hadj.StepIncrement;
+					if (hadj.Value > hadj.Upper - hadj.PageSize)
+						hadj.Value = hadj.Upper - hadj.PageSize;
 					return;
 				}
 			}
-
+			
+			// Go to the next/previous photo when not zoomed (no scrollbars)
 			switch (args.Event.Key) {
 			case Gdk.Key.Up:
+			case Gdk.Key.KP_Up:
 			case Gdk.Key.Left:
+			case Gdk.Key.KP_Left:
 			case Gdk.Key.Page_Up:
 			case Gdk.Key.KP_Page_Up:
+			case Gdk.Key.BackSpace:
+			case Gdk.Key.h:
+			case Gdk.Key.H:
+			case Gdk.Key.j:
+			case Gdk.Key.J:
+			case Gdk.Key.b:
+			case Gdk.Key.B:
 				this.Item.MovePrevious ();
 				break;
-			case Gdk.Key.Home:
-			case Gdk.Key.KP_Home:
-				this.Item.Index = 0;
-				break;
-			case Gdk.Key.End:
-			case Gdk.Key.KP_End:
-				this.Item.Index = this.Query.Count - 1;
-				break;
 			case Gdk.Key.Down:
+			case Gdk.Key.KP_Down:
 			case Gdk.Key.Right:
+			case Gdk.Key.KP_Right:
 			case Gdk.Key.Page_Down:
 			case Gdk.Key.KP_Page_Down:
 			case Gdk.Key.space:
 			case Gdk.Key.KP_Space:
+			case Gdk.Key.k:
+			case Gdk.Key.K:
+			case Gdk.Key.l:
+			case Gdk.Key.L:
+			case Gdk.Key.n:
+			case Gdk.Key.N:
 				this.Item.MoveNext ();
 				break;
+			case Gdk.Key.Home:
+			case Gdk.Key.KP_Home:
+				this.Item.Index = 0;
+				break;
+			case Gdk.Key.End:
+			case Gdk.Key.KP_End:
+				this.Item.Index = this.Query.Count - 1;
+				break;
 			case Gdk.Key.Key_0:
 			case Gdk.Key.KP_0:
 				if (alt) 



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