[mistelix] Fixes issue #584480 & disables sound for preview (Dani's implementation never worked)



commit e51fca88e4054edad9b3d5c00005e452fbb96a18
Author: Jordi Mas <jmas softcatala org>
Date:   Thu Jul 9 15:23:00 2009 +0100

    Fixes issue #584480 & disables sound for preview (Dani's implementation never worked)

 src/dialogs/AddSlideDialog.cs     |   49 ++++++++++++++++++++++++++++++++++--
 src/mistelix.cs                   |    9 +++----
 src/mistelix.glade                |    2 +-
 src/widgets/PixbufImageSurface.cs |    7 +----
 src/widgets/ProjectElementView.cs |   10 ++++----
 src/widgets/SlideShowView.cs      |   29 ++++++++++------------
 6 files changed, 70 insertions(+), 36 deletions(-)
---
diff --git a/src/dialogs/AddSlideDialog.cs b/src/dialogs/AddSlideDialog.cs
index 0462b20..50d51f1 100644
--- a/src/dialogs/AddSlideDialog.cs
+++ b/src/dialogs/AddSlideDialog.cs
@@ -37,6 +37,49 @@ using Mistelix.Core;
 
 namespace Mistelix.Dialogs
 {
+	//
+	// This class supports the execution of AddSlideDialog. When running as a Modal dialog box the Run loop exists when we change
+	// visibility, something that we need to do when previewing the slideshow. This class encapsulates the running context
+	//
+	static public class AddSlideDialogRunner
+	{
+		static AddSlideDialog dialog;
+		static ResponseType response;
+
+		static AddSlideDialogRunner ()
+		{
+
+		}
+
+		static public AddSlideDialog Dialog {
+			get {return dialog; }
+		}
+
+		static public void Create (Project project)
+		{
+			if (dialog != null)
+				dialog.Destroy ();
+
+			dialog = new AddSlideDialog (project);
+		}
+
+		static public ResponseType Run ()
+		{
+			response = dialog.RunNoDestroy ();
+			return response;
+		}
+
+		static public void ProcessResponse ()
+		{
+			// ResponseType.None is returned when the loop exits with no action (change dlg box visiblity)
+			if (response == ResponseType.None) 
+				return;
+
+			dialog.Destroy ();
+			dialog = null;
+		}
+	}
+
 	// UI interface to create new Slideshows
 	public class AddSlideDialog : GtkDialog
 	{
@@ -77,7 +120,7 @@ namespace Mistelix.Dialogs
 		{
 			this.project = project;
 			LoadWindowPosition ();
-			
+
 			image_view = new SlideShowImageView ();
 			image_view.ChangeEvent = new ShowImageSelectionEventHandler (OnChangeImage);
 			image_view.UpdatedElements = new ShowImageUpdatedElementsEventHandler (OnUpdatedImages);
@@ -328,8 +371,8 @@ namespace Mistelix.Dialogs
 		{
 			SlideShow slide_show = GenerateSlideShow ();
 			SlideShowView slide_show_view = new SlideShowView(slide_show);
-			FullScreenWindow full_screen = new FullScreenWindow(slide_show_view);
-			Dialog.Respond (ResponseType.Ok);
+			Dialog.Visible = false;
+			FullScreenWindow full_screen = new FullScreenWindow (slide_show_view);
 		}
 
 		// If there are at least two elements we enable the navigation buttons
diff --git a/src/mistelix.cs b/src/mistelix.cs
index ef69bd0..e2916ae 100644
--- a/src/mistelix.cs
+++ b/src/mistelix.cs
@@ -194,11 +194,10 @@ namespace Mistelix
 
 		void OnAddSlideShow (object sender, EventArgs args)
 		{
-			AddSlideDialog dialog = new AddSlideDialog (this.project);
+			AddSlideDialogRunner.Create (project);
 
-			if (dialog.RunNoDestroy () == ResponseType.Ok) {
-
-				SlideShow slideshow = dialog.GenerateSlideShow ();
+			if (AddSlideDialogRunner.Run () == ResponseType.Ok) {
+				SlideShow slideshow = AddSlideDialogRunner.Dialog.GenerateSlideShow ();
 
 				if (slideshow.images.Count > 0) {
 					Logger.Debug ("Mistelix.OnSlideshowsButtonClicked. Ok");
@@ -206,7 +205,7 @@ namespace Mistelix
 					element_view.AddElement (slideshow);
 				}
 			}
-			dialog.Destroy ();
+			AddSlideDialogRunner.ProcessResponse ();
 		}
 
 		void OnPreferences (object sender, EventArgs args)
diff --git a/src/mistelix.glade b/src/mistelix.glade
index da8d64a..4eca3a2 100644
--- a/src/mistelix.glade
+++ b/src/mistelix.glade
@@ -835,7 +835,7 @@
 			  <property name="spacing">0</property>
 
 			  <child>
-			    <widget class="GtkButton" id="generate">
+			    <widget class="GtkButton" id="saveslide">
 			      <property name="visible">True</property>
 			      <property name="can_default">True</property>
 			      <property name="can_focus">True</property>
diff --git a/src/widgets/PixbufImageSurface.cs b/src/widgets/PixbufImageSurface.cs
index 673c03c..19da8c0 100644
--- a/src/widgets/PixbufImageSurface.cs
+++ b/src/widgets/PixbufImageSurface.cs
@@ -30,12 +30,7 @@ using Cairo;
 namespace Mistelix.Widgets
 {
 	public class PixbufImageSurface : DataImageSurface, IDisposable
-	{ 
-		private static void DestroyPixelData (IntPtr data)
-		{
-			Marshal.FreeHGlobal (data);
-		}
-
+	{
 		public PixbufImageSurface (Gdk.Pixbuf pixbuf) : this (pixbuf, false)
 		{
 		}
diff --git a/src/widgets/ProjectElementView.cs b/src/widgets/ProjectElementView.cs
index 2b2d1f8..0b07c98 100644
--- a/src/widgets/ProjectElementView.cs
+++ b/src/widgets/ProjectElementView.cs
@@ -270,20 +270,20 @@ namespace Mistelix.Widgets
 			if (current.GetType () != typeof (SlideShow))
 				return;
 
-			AddSlideDialog dialog = new AddSlideDialog (this.project);
-			dialog.LoadSlideShow ((SlideShow) current);
+			AddSlideDialogRunner.Create (project);
+			AddSlideDialogRunner.Dialog.LoadSlideShow ((SlideShow) current);
 
-			if (dialog.RunNoDestroy () == ResponseType.Ok) {
+			if (AddSlideDialogRunner.Run () == ResponseType.Ok) {
 				for (int i = 0; i < project.Elements.Count; i++)
 				{
 					if (current == project.Elements[i]) {
-						project.Elements[i] = dialog.GenerateSlideShow ();
+						project.Elements[i] = AddSlideDialogRunner.Dialog.GenerateSlideShow ();
 						UpdateElement (project.Elements[i]);
 						break;
 					}
 				}
 			}
-			dialog.Destroy ();
+			AddSlideDialogRunner.ProcessResponse ();
 		}
 
 		[GLib.ConnectBefore]
diff --git a/src/widgets/SlideShowView.cs b/src/widgets/SlideShowView.cs
index 06d1d4c..463dfe2 100644
--- a/src/widgets/SlideShowView.cs
+++ b/src/widgets/SlideShowView.cs
@@ -1,5 +1,6 @@
 //
 // Copyright (C) 2009 Dani Hernandez Juarez, dhernandez0 gmail com
+//		 2009 Jordi Mas i Hernàndez, jmas softcatala org
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -32,31 +33,25 @@ using Mono.Unix;
 using Mistelix.Core;
 using Mistelix.DataModel;
 using Mistelix.Transitions;
+using Mistelix.Dialogs;
 
 namespace Mistelix.Widgets
 {	
 	public class FullScreenWindow : Gtk.Window
 	{
 		SlideShowView slide_show_view;
-		static readonly string WindowTitle;
-		
-		static FullScreenWindow()
-		{
-			WindowTitle = Catalog.GetString("Slideshow preview");
-		}
 		
 		public FullScreenWindow(SlideShowView slide_show_view) : base(Gtk.WindowType.Toplevel)
 		{
 			if(slide_show_view == null)
 				throw new System.ArgumentException("SlideShowView shouldn't be null");
 			this.slide_show_view = slide_show_view;
-			Title = WindowTitle;
+			Title = Catalog.GetString("Slideshow preview");
 			KeyPressEvent += HandleSlideViewKeyPressEvent;
 			Decorated = false;
 			Fullscreen();
 			Add(slide_show_view);
 			ShowAll();
-			this.slide_show_view.Start();
 		}
 		
 		[GLib.ConnectBefore]
@@ -78,6 +73,9 @@ namespace Mistelix.Widgets
 				slide_show_view.Destroy ();
 				args.RetVal = true;
 				this.Destroy ();
+				AddSlideDialogRunner.Dialog.Dialog.Visible = true;
+				AddSlideDialogRunner.Run ();
+				AddSlideDialogRunner.ProcessResponse ();
 				break;
 			}
 		}
@@ -94,6 +92,8 @@ namespace Mistelix.Widgets
 		SoundPlayer player;
 		bool paused = false;
 		const uint MinTime = 100;
+		bool started = false;
+
 		int CurrentIndex {
 			set {
 				if(current_index_image == value)
@@ -114,18 +114,12 @@ namespace Mistelix.Widgets
 				throw new System.ArgumentException("Slide cannot be null and should have an image at least");
 			this.slide = slide;
 			this.current_index_image = 0;
-			if(slide.AudioFile != null) {
-				player = new SoundPlayer(slide.AudioFile);
-				player.Load();
-			}
 		}
 		
 		#region public methods
 		public void Start() {
 			if(current_image == null)
 				CurrentIndex = 0;
-			if (player != null)
-				player.PlayLooping();
 
 			if (slide.images.Count == 1) // Single image, just show it
 				current_image = ResizeImage (CurrentIndex);
@@ -135,8 +129,6 @@ namespace Mistelix.Widgets
 		}
 		
 		public void Pause() {
-			if (player != null)
-				player.Stop();
 			paused = true;
 		}
 		
@@ -245,6 +237,11 @@ namespace Mistelix.Widgets
 		#region event callbacks
 		protected override bool OnExposeEvent (Gdk.EventExpose args)
 		{
+			if (started == false) {
+				started = true;
+				Start ();
+			}
+
 			if(current_image != null) {
 				ShowImage(current_image);
 			}



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