f-spot r4399 - in trunk: . libfspot src src/Utils



Author: sdelcroix
Date: Wed Sep 17 13:04:00 2008
New Revision: 4399
URL: http://svn.gnome.org/viewvc/f-spot?rev=4399&view=rev

Log:
2008-09-15  Anton Keks  <anton azib net>

	* src/SlideView.cs
	* src/Utils/GdkUtils.cs: moved empty cursor creation code to GdkUtils.

	* libfspot/f-image-view.c
	* src/FullScreenView.cs: hides cursor automatically when entering full
	screen. Moving the mouse will show cursor again for 3 seconds.


Modified:
   trunk/ChangeLog
   trunk/libfspot/f-image-view.c
   trunk/src/FullScreenView.cs
   trunk/src/SlideView.cs
   trunk/src/Utils/GdkUtils.cs

Modified: trunk/libfspot/f-image-view.c
==============================================================================
--- trunk/libfspot/f-image-view.c	(original)
+++ trunk/libfspot/f-image-view.c	Wed Sep 17 13:04:00 2008
@@ -217,6 +217,9 @@
 {
 	GdkCursor *cursor = NULL;
 
+	if (!GDK_IS_WINDOW(GTK_WIDGET (image_view)->window)) 
+		return;
+	
 	if (image_view->priv->mode != MODE_IDLE) {
 		cursor = get_cursor_for_mode (image_view, image_view->priv->mode);
 	} else {
@@ -926,6 +929,7 @@
 			       FImageViewPointerMode mode)
 {
 	image_view->priv->pointer_mode = mode;
+    	set_cursor (image_view);
 }
 
 FImageViewPointerMode

Modified: trunk/src/FullScreenView.cs
==============================================================================
--- trunk/src/FullScreenView.cs	(original)
+++ trunk/src/FullScreenView.cs	Wed Sep 17 13:04:00 2008
@@ -25,6 +25,7 @@
 		private TextureDisplay display;
 		private ToolButton play_pause_button;
 		private ToggleToolButton info_button;
+		private Delay hide_cursor_delay;
 
 		ActionGroup actions;
 		const string ExitFullScreen = "ExitFullScreen";
@@ -100,10 +101,10 @@
 				view = new PhotoImageView (collection);
 				// FIXME this should be handled by the new style setting code
 				view.ModifyBg (Gtk.StateType.Normal, this.Style.Black);
-				view.PointerMode = ImageView.PointerModeType.Scroll;
 				this.Add (notebook);
 				view.Show ();
 				view.MotionNotifyEvent += HandleViewMotion;
+				view.PointerMode = ImageView.PointerModeType.Scroll;
 				
 				scroll.ScrolledWindow.Add (view);
 
@@ -196,6 +197,9 @@
 				
 				view.Item.Changed += HandleItemChanged;
 				view.GrabFocus ();
+
+				hide_cursor_delay = new Delay (3000, new GLib.IdleHandler (HideCursor));
+				hide_cursor_delay.Start ();
 				
 				controls = new ControlOverlay (this);
 				controls.Add (tbar);
@@ -205,33 +209,42 @@
 			} catch (System.Exception e) {
 				Log.Exception (e);
 			}	
-
 		}
 
+		private Gdk.Cursor empty_cursor;
+		private bool HideCursor ()
+		{
+			if (empty_cursor == null) 
+				empty_cursor = GdkUtils.CreateEmptyCursor (GdkWindow.Display);
+			
+			this.GdkWindow.Cursor = empty_cursor;
+			view.GdkWindow.Cursor = empty_cursor;
+			return false;
+		}
+		
+		private void ShowCursor () 
+		{
+			view.PointerMode = ImageView.PointerModeType.Scroll;
+			this.GdkWindow.Cursor = null;
+		}
+		
 		private void HandleItemChanged (object sender, BrowsablePointerChangedArgs args)
 		{
 			if (scroll.ControlBox.Visible)
 				scroll.ShowControls ();
 		}
-#if false
+
 		protected override bool OnExposeEvent (Gdk.EventExpose args)
 		{
 			bool ret = base.OnExposeEvent (args);
-			Graphics g = CairoHelper.Create (GdkWindow);
-
-			g.Color = new Cairo.Color (0, 0, 0, .5);
-			g.Operator = Operator.DestOut;
-			g.Rectangle (0, 0, Allocation.Width  * .5, Allocation.Height);
-			g.Paint ();
 
+			HideCursor ();
 			return ret;
 		}
-#endif
 		
 		private void ExitAction (object sender, System.EventArgs args)
 		{
-			display.Dispose ();
-			this.Destroy ();
+			Quit ();
 		}
 
 		private void HideToolbarAction (object sender, System.EventArgs args)
@@ -267,6 +280,9 @@
 		[GLib.ConnectBefore]
 		private void HandleViewMotion (object sender, Gtk.MotionNotifyEventArgs args)
 		{
+			ShowCursor ();
+			hide_cursor_delay.Restart ();
+			
 			int x, y;
 			Gdk.ModifierType type;
 			((Gtk.Widget)sender).GdkWindow.GetPointer (out x, out y, out type);
@@ -310,7 +326,9 @@
 
 		public void Quit ()
 		{
+			hide_cursor_delay.Stop ();
 			FSpot.Utils.ScreenSaver.UnInhibit ();
+
 			this.Destroy ();
 		}
 

Modified: trunk/src/SlideView.cs
==============================================================================
--- trunk/src/SlideView.cs	(original)
+++ trunk/src/SlideView.cs	Wed Sep 17 13:04:00 2008
@@ -6,6 +6,7 @@
 using GLib;
 using System.Runtime.InteropServices;
 using FSpot;
+using FSpot.Utils;
 
 namespace FSpot {
 	public class XScreenSaverSlide : Gtk.Window {
@@ -85,29 +86,11 @@
 
 			busy = new Gdk.Cursor (Gdk.CursorType.Watch);
 			this.GdkWindow.Cursor = busy;
-			none = Empty ();
+			none = GdkUtils.CreateEmptyCursor (GdkWindow.Display);
 
 			hide = new Delay (2000, new GLib.IdleHandler (HideCursor));
 		}
 
-		public Gdk.Cursor Empty () 
-		{
-			Gdk.Cursor cempty = null;
-			
-			try {
-				Gdk.Pixbuf empty = new Gdk.Pixbuf (Gdk.Colorspace.Rgb, true, 8, 1, 1);
-			        empty.Fill (0x00000000);
-				cempty = new Gdk.Cursor (GdkWindow.Display, empty, 0, 0);
-			} catch (System.Exception e){
-				System.Console.WriteLine (e.ToString ());
-				return null;
-			}
-
-			return cempty;
-		}
-
-
-
 		public void Play ()
 		{
 			Gdk.GCValues values = new Gdk.GCValues ();

Modified: trunk/src/Utils/GdkUtils.cs
==============================================================================
--- trunk/src/Utils/GdkUtils.cs	(original)
+++ trunk/src/Utils/GdkUtils.cs	Wed Sep 17 13:04:00 2008
@@ -48,5 +48,17 @@
 		{
 			return (Gdk.Visual) GLib.Object.GetObject (NativeMethods.gdk_x11_screen_lookup_visual (screen.Handle, visualid));
 		}
+		
+		public static Cursor CreateEmptyCursor (Display display) 
+		{
+			try {
+				Gdk.Pixbuf empty = new Gdk.Pixbuf (Gdk.Colorspace.Rgb, true, 8, 1, 1);
+				empty.Fill (0x00000000);
+				return new Gdk.Cursor (display, empty, 0, 0);
+			} catch (System.Exception e){
+				Log.Exception (e);
+				return null;
+			}
+		}
 	}
 }



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