gnome-subtitles r971 - in trunk: . src/Glade src/GnomeSubtitles/Core src/GnomeSubtitles/SubtitleEdit



Author: pcastro
Date: Sun Mar  9 13:57:43 2008
New Revision: 971
URL: http://svn.gnome.org/viewvc/gnome-subtitles?rev=971&view=rev

Log:
Fixed a bug that happend when setting a language for the first time with spellchecking enabled.

Modified:
   trunk/gnome-subtitles.mdp
   trunk/src/Glade/MainWindow.glade
   trunk/src/GnomeSubtitles/Core/SpellLanguages.cs
   trunk/src/GnomeSubtitles/SubtitleEdit/SubtitleEditTextView.cs

Modified: trunk/gnome-subtitles.mdp
==============================================================================
--- trunk/gnome-subtitles.mdp	(original)
+++ trunk/gnome-subtitles.mdp	Sun Mar  9 13:57:43 2008
@@ -121,6 +121,7 @@
     <File name="./src/GnomeSubtitles/Dialogs/SetLanguageDialog.cs" subtype="Code" buildaction="Compile" />
     <File name="./src/GnomeSubtitles/Core/SpellLanguages.cs" subtype="Code" buildaction="Compile" />
     <File name="./src/Glade/SetLanguageDialog.glade" subtype="Code" buildaction="EmbedAsResource" />
+    <File name="./src/GnomeSubtitles/Execution/gnome-subtitles.exe.config" subtype="Code" buildaction="EmbedAsResource" />
   </Contents>
   <References>
     <ProjectReference type="Gac" localcopy="True" refto="gtk-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />

Modified: trunk/src/Glade/MainWindow.glade
==============================================================================
--- trunk/src/Glade/MainWindow.glade	(original)
+++ trunk/src/Glade/MainWindow.glade	Sun Mar  9 13:57:43 2008
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
-<!--Generated with glade3 3.4.0 on Sat Mar  8 12:19:09 2008 
+<!--Generated with glade3 3.4.0 on Sat Mar  8 12:33:18 2008 
 	Version: 3.0.1
 	Date: Thu Dec  7 16:42:10 2006
 	User: noup

Modified: trunk/src/GnomeSubtitles/Core/SpellLanguages.cs
==============================================================================
--- trunk/src/GnomeSubtitles/Core/SpellLanguages.cs	(original)
+++ trunk/src/GnomeSubtitles/Core/SpellLanguages.cs	Sun Mar  9 13:57:43 2008
@@ -127,13 +127,13 @@
 	
 	/* LibEnchant imports */
 	
-	[DllImport ("libenchant.so.1")]
+	[DllImport ("libenchant")]
 	static extern IntPtr enchant_broker_init ();
 	
-	[DllImport ("libenchant.so.1")]
+	[DllImport ("libenchant")]
 	static extern void enchant_broker_free (IntPtr broker);
 	
-	[DllImport ("libenchant.so.1")]
+	[DllImport ("libenchant")]
 	static extern void enchant_broker_list_dicts (IntPtr broker, LanguageListHandler cb, IntPtr userdata);
 
 	

Modified: trunk/src/GnomeSubtitles/SubtitleEdit/SubtitleEditTextView.cs
==============================================================================
--- trunk/src/GnomeSubtitles/SubtitleEdit/SubtitleEditTextView.cs	(original)
+++ trunk/src/GnomeSubtitles/SubtitleEdit/SubtitleEditTextView.cs	Sun Mar  9 13:57:43 2008
@@ -195,29 +195,46 @@
     }
 
     /* GtkSpell */
-	[DllImport ("libgtkspell.so.0")]
+	[DllImport ("libgtkspell")]
 	static extern IntPtr gtkspell_new_attach (IntPtr textView, string locale, IntPtr error);
 
-	[DllImport ("libgtkspell.so.0")]
+	[DllImport ("libgtkspell")]
 	static extern void gtkspell_detach (IntPtr obj);
 
-	[DllImport ("libgtkspell.so.0")]
+	[DllImport ("libgtkspell")]
 	static extern bool gtkspell_set_language (IntPtr textView, string lang, IntPtr error);
 	
 	private void GtkSpellDetach () {
-		if (spellTextView != IntPtr.Zero)
+		if (IsGtkSpellAttached()) {
 			gtkspell_detach(spellTextView);
+			spellTextView = IntPtr.Zero;
+		}
 	}
 	
 	private void GtkSpellAttach () {
-		spellTextView = gtkspell_new_attach(textView.Handle, null, IntPtr.Zero);
+		if (!IsGtkSpellAttached()) {
+			spellTextView = gtkspell_new_attach(textView.Handle, null, IntPtr.Zero);
+		}
+	}
+	
+	private bool IsGtkSpellAttached () {
+		return (spellTextView != IntPtr.Zero);
 	}
 	
 	private bool GtkSpellSetLanguage (string language) {
-		if ((language == null) || (language == String.Empty))
+		bool isEmpty = ((language == null) || (language == String.Empty));
+		if (isEmpty) {
+			if (IsGtkSpellAttached()) {
+				GtkSpellDetach();
+			}
 			return false;
-		else
+		}
+		else {
+			if (!IsGtkSpellAttached()) {
+				GtkSpellAttach();
+			}
 			return gtkspell_set_language(spellTextView, language, IntPtr.Zero);
+		}
 	}
 	
 
@@ -425,6 +442,8 @@
     		this.ToggleOverwrite(this, EventArgs.Empty);
     }
     
+    /* Protected members */
+    
     protected void OnSpellLanguageChanged (object o, EventArgs args) {
 		if (Global.SpellLanguages.Enabled) {
 			string language = GetSpellActiveLanguage();



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