[gbrainy] Reload background when user changes theme



commit 8dbef5844446ba5a40b707f91223d0822379312b
Author: Jordi Mas <jmas softcatala org>
Date:   Thu May 19 20:00:06 2011 +0200

    Reload background when user changes theme

 src/Clients/Classical/Dialogs/PreferencesDialog.cs |    4 ++++
 src/Clients/Classical/gbrainy.cs                   |    3 +++
 src/Core/Main/CairoContextEx.cs                    |    9 +++++++++
 3 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/src/Clients/Classical/Dialogs/PreferencesDialog.cs b/src/Clients/Classical/Dialogs/PreferencesDialog.cs
index 172abe3..9d85f55 100644
--- a/src/Clients/Classical/Dialogs/PreferencesDialog.cs
+++ b/src/Clients/Classical/Dialogs/PreferencesDialog.cs
@@ -100,6 +100,8 @@ namespace gbrainy.Clients.Classical.Dialogs
 			}
 		}
 
+		public bool NewThemeSet {set; get; }
+
 		private void OnCleanHistory (object sender, EventArgs args)
 		{
 			if (ResponseType.Ok == HigMessageDialog.RunHigConfirmation (
@@ -127,6 +129,8 @@ namespace gbrainy.Clients.Classical.Dialogs
 			TreeIter iter;
 			themes_combobox.GetActiveIter (out iter);
 			Theme theme = (Theme) themes_combobox.Model.GetValue (iter, COLUMN_VALUE);
+
+			NewThemeSet = String.Compare (theme.Name, Preferences.Get <string> (Preferences.ThemeKey), true) != 0;
 			Preferences.Set <string> (Preferences.ThemeKey, theme.Name);
 
 			Preferences.Save ();
diff --git a/src/Clients/Classical/gbrainy.cs b/src/Clients/Classical/gbrainy.cs
index 062e43c..3595d11 100644
--- a/src/Clients/Classical/gbrainy.cs
+++ b/src/Clients/Classical/gbrainy.cs
@@ -563,6 +563,9 @@ namespace gbrainy.Clients.Classical
 			dialog = new PreferencesDialog (session.PlayerHistory);
 			if ((Gtk.ResponseType) dialog.Run () == ResponseType.Ok) {
 				session.Difficulty = (GameDifficulty) Preferences.Get <int> (Preferences.DifficultyKey);
+
+				if (dialog.NewThemeSet == true)
+					drawing_area.ReloadBackground ();
 			}
 			dialog.Destroy ();
 		}
diff --git a/src/Core/Main/CairoContextEx.cs b/src/Core/Main/CairoContextEx.cs
index d8f9fed..fe90e79 100644
--- a/src/Core/Main/CairoContextEx.cs
+++ b/src/Core/Main/CairoContextEx.cs
@@ -49,6 +49,15 @@ namespace gbrainy.Core.Main
 
 			SetPangoNormalFontSize ();
 		}
+		
+		public static void ResetDrawBackgroundCache ()
+		{
+			if (image == null)
+				return;
+
+			image.Dispose ();
+			image = null;
+		}
 
 		virtual public void DrawBackground ()
 		{



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