diff options
author | Lluis Sanchez Gual <lluis@xamarin.com> | 2015-04-20 19:07:51 +0300 |
---|---|---|
committer | Lluis Sanchez Gual <lluis@xamarin.com> | 2015-04-20 19:07:51 +0300 |
commit | 95408b1a41b31b645f3a8c3323ab7d3ca4bff26b (patch) | |
tree | f8f137cddcb9a40499d303be95722fd2c6081bce /main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.Editor | |
parent | b70e4e04b4e41b8ec28d7e4b220b401ecf467e7a (diff) | |
parent | de043d330a8bf5855d4d983c804cd36727cb2406 (diff) |
Merge remote-tracking branch 'origin/roslyn' into new-project-model
Diffstat (limited to 'main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.Editor')
-rw-r--r-- | main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.Editor/CatalogEditorView.cs | 9 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.Editor/POEditorWidget.cs | 100 |
2 files changed, 47 insertions, 62 deletions
diff --git a/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.Editor/CatalogEditorView.cs b/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.Editor/CatalogEditorView.cs index a8b406d6fd..cc9aef04b0 100644 --- a/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.Editor/CatalogEditorView.cs +++ b/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.Editor/CatalogEditorView.cs @@ -52,8 +52,9 @@ namespace MonoDevelop.Gettext.Editor }; } - public override void Load (string fileName)
+ public override void Load (FileOpenInformation fileOpenInformation)
{ + var fileName = fileOpenInformation.FileName; // using (IProgressMonitor mon = IdeApp.Workbench.ProgressMonitors.GetLoadProgressMonitor (true)) { catalog.Load (null, fileName); // } @@ -65,11 +66,11 @@ namespace MonoDevelop.Gettext.Editor this.IsDirty = false; } - public override void Save (string fileName)
+ public override void Save (FileSaveInformation fileSaveInformation)
{ OnBeforeSave (EventArgs.Empty); - catalog.Save (fileName); - ContentName = fileName; + catalog.Save (fileSaveInformation.FileName); + ContentName = fileSaveInformation.FileName; IsDirty = false;
} diff --git a/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.Editor/POEditorWidget.cs b/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.Editor/POEditorWidget.cs index 21de4f4562..40930f4b0d 100644 --- a/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.Editor/POEditorWidget.cs +++ b/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.Editor/POEditorWidget.cs @@ -38,12 +38,13 @@ using MonoDevelop.Core; using MonoDevelop.Ide.Gui.Content; using MonoDevelop.Ide.Tasks; using MonoDevelop.Gettext.Editor; -using Mono.TextEditor; using MonoDevelop.Ide.Gui.Components; using MonoDevelop.Ide; using System.ComponentModel; using System.Threading; using MonoDevelop.Components; +using MonoDevelop.Ide.Editor; +using MonoDevelop.Core.Text; namespace MonoDevelop.Gettext { @@ -55,9 +56,8 @@ namespace MonoDevelop.Gettext ListStore foundInStore; Catalog catalog; string poFileName; - Mono.TextEditor.TextEditorOptions options = new Mono.TextEditor.TextEditorOptions (); - Mono.TextEditor.TextEditor texteditorOriginal = new Mono.TextEditor.TextEditor (); - Mono.TextEditor.TextEditor texteditorPlural = new Mono.TextEditor.TextEditor (); + TextEditor texteditorOriginal = TextEditorFactory.CreateNewEditor (); + TextEditor texteditorPlural = TextEditorFactory.CreateNewEditor (); static List<POEditorWidget> widgets = new List<POEditorWidget> (); @@ -239,22 +239,17 @@ namespace MonoDevelop.Gettext widgets.Add (this); checkbuttonWhiteSpaces.Toggled += CheckbuttonWhiteSpacesToggled; - options.ShowLineNumberMargin = false; - options.ShowFoldMargin = false; - options.ShowIconMargin = false; - options.ColorScheme = IdeApp.Preferences.ColorScheme; - options.FontName = PropertyService.Get<string> ("FontName"); - + this.scrolledwindowOriginal.Child = this.texteditorOriginal; this.scrolledwindowPlural.Child = this.texteditorPlural; - this.texteditorOriginal.Show (); - this.texteditorPlural.Show (); - texteditorOriginal.ModifyBase (Gtk.StateType.Normal, Style.Base (Gtk.StateType.Insensitive)); - texteditorPlural.ModifyBase (Gtk.StateType.Normal, Style.Base (Gtk.StateType.Insensitive)); - this.texteditorOriginal.Options = options; - this.texteditorPlural.Options = options; - this.texteditorOriginal.Document.ReadOnly = true; - this.texteditorPlural.Document.ReadOnly = true; + this.scrolledwindowOriginal.Child.Show (); + this.scrolledwindowPlural.Child.Show (); + scrolledwindowOriginal.Child.ModifyBase (Gtk.StateType.Normal, Style.Base (Gtk.StateType.Insensitive)); + scrolledwindowPlural.Child.ModifyBase (Gtk.StateType.Normal, Style.Base (Gtk.StateType.Insensitive)); + this.texteditorOriginal.Options = DefaultSourceEditorOptions.PlainEditor; + this.texteditorPlural.Options = DefaultSourceEditorOptions.PlainEditor; + this.texteditorOriginal.IsReadOnly = true; + this.texteditorPlural.IsReadOnly = true; } void HandleCellRendFuzzyToggled (object sender, ToggledArgs args) @@ -299,13 +294,6 @@ namespace MonoDevelop.Gettext void CheckbuttonWhiteSpacesToggled (object sender, EventArgs e) { - texteditorOriginal.QueueDraw (); - texteditorPlural.QueueDraw (); - for (int i = this.notebookTranslated.NPages - 1; i >= 0; i--) { - Mono.TextEditor.TextEditor view = GetTextView (i); - if (view != null) - view.QueueDraw (); - } } #region Options @@ -467,13 +455,10 @@ namespace MonoDevelop.Gettext this.Catalog = newCatalog; UpdateTasks (); } - - Mono.TextEditor.TextEditor GetTextView (int index) + List<TextEditor> notebookTranslatedEditors = new List<TextEditor> (); + TextEditor GetTextView (int index) { - ScrolledWindow window = this.notebookTranslated.GetNthPage (index) as ScrolledWindow; - if (window != null) - return window.Child as Mono.TextEditor.TextEditor; - return null; + return notebookTranslatedEditors[index]; } void ClearTextview () @@ -485,24 +470,23 @@ namespace MonoDevelop.Gettext void AddTextview (int index) { ScrolledWindow window = new ScrolledWindow (); - Mono.TextEditor.TextEditor textView = new Mono.TextEditor.TextEditor (); + var textView = TextEditorFactory.CreateNewEditor (); window.Child = textView; - textView.Options = options; - textView.Document.TextReplaced += delegate { + textView.TextChanged += delegate { if (this.isUpdating) return; try { if (this.currentEntry != null) { - string escapedText = textView.Document.Text; + string escapedText = textView.Text; string oldText = this.currentEntry.GetTranslation (index); this.currentEntry.SetTranslation (escapedText, index); AddChange (this.currentEntry, oldText, escapedText, index); } IdeApp.Workbench.StatusBar.ShowReady (); - textView.ModifyBase (Gtk.StateType.Normal, Style.Base (Gtk.StateType.Normal)); + window.Child.ModifyBase (Gtk.StateType.Normal, Style.Base (Gtk.StateType.Normal)); } catch (System.Exception e) { IdeApp.Workbench.StatusBar.ShowError (e.Message); - textView.ModifyBase (Gtk.StateType.Normal, errorColor); + window.Child.ModifyBase (Gtk.StateType.Normal, errorColor); } treeviewEntries.QueueDraw (); UpdateProgressBar (); @@ -513,6 +497,7 @@ namespace MonoDevelop.Gettext label.Text = this.Catalog.PluralFormsDescriptions [index]; window.ShowAll (); this.notebookTranslated.AppendPage (window, label); + notebookTranslatedEditors.Add (textView); } void ShowPopup (EventButton evt) @@ -601,14 +586,15 @@ namespace MonoDevelop.Gettext void RemoveTextViewsFrom (int index) { for (int i = this.notebookTranslated.NPages - 1; i >= index; i--) { - Mono.TextEditor.TextEditor view = GetTextView (i); + var view = GetTextView (i); if (view == null) continue; // if (gtkSpellSet.ContainsKey (view)) { // GtkSpell.Detach (view); // gtkSpellSet.Remove (view); // } - this.notebookTranslated.RemovePage (i); + notebookTranslated.RemovePage (i); + notebookTranslatedEditors.RemoveAt (i); } } @@ -617,9 +603,9 @@ namespace MonoDevelop.Gettext this.isUpdating = true; try { currentEntry = entry; - this.texteditorOriginal.Caret.Location = new DocumentLocation (1, 1); - this.texteditorOriginal.Document.Text = entry != null ? entry.String : ""; - this.texteditorOriginal.VAdjustment.Value = this.texteditorOriginal.HAdjustment.Value = 0; + this.texteditorOriginal.CaretLocation = new DocumentLocation (1, 1); + this.texteditorOriginal.Text = entry != null ? entry.String : ""; + //this.texteditorOriginal.VAdjustment.Value = this.texteditorOriginal.HAdjustment.Value = 0; // if (GtkSpell.IsSupported && !gtkSpellSet.ContainsKey (this.textviewOriginal)) { // GtkSpell.Attach (this.textviewOriginal, "en"); @@ -630,9 +616,9 @@ namespace MonoDevelop.Gettext this.notebookTranslated.ShowTabs = entry != null && entry.HasPlural; if (entry != null && entry.HasPlural) { - this.texteditorPlural.Caret.Location = new DocumentLocation (1, 1); - this.texteditorPlural.Document.Text = entry.PluralString; - this.texteditorPlural.VAdjustment.Value = this.texteditorPlural.HAdjustment.Value = 0; + this.texteditorPlural.CaretLocation = new DocumentLocation (1, 1); + this.texteditorPlural.Text = entry.PluralString; + //this.texteditorPlural.VAdjustment.Value = this.texteditorPlural.HAdjustment.Value = 0; // if (GtkSpell.IsSupported && !gtkSpellSet.ContainsKey (this.textviewOriginalPlural)) { // GtkSpell.Attach (this.textviewOriginalPlural, "en"); // this.gtkSpellSet[this.textviewOriginalPlural] = true; @@ -649,14 +635,12 @@ namespace MonoDevelop.Gettext } for (int i = 0; i < entry.NumberOfTranslations; i++) { - Mono.TextEditor.TextEditor textView = GetTextView (i); + var textView = GetTextView (i); if (textView == null) continue; textView.ClearSelection (); - textView.Document.Text = entry != null ? entry.GetTranslation (i) : ""; - textView.Caret.Offset = textView.Document.Text.Length; - textView.VAdjustment.Value = textView.HAdjustment.Value = 0; - textView.Document.CommitUpdateAll (); + textView.Text = entry != null ? entry.GetTranslation (i) : ""; + EditActions.MoveCaretToDocumentEnd (textView); } foreach (string reference in entry.References) { @@ -810,7 +794,7 @@ namespace MonoDevelop.Gettext } string filter = ""; - Regex regex = new Regex (""); + System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex (""); void UpdateFromCatalog () { @@ -822,7 +806,7 @@ namespace MonoDevelop.Gettext RegexOptions options = RegexOptions.Compiled; if (!IsCaseSensitive) options |= RegexOptions.IgnoreCase; - regex = new Regex (filter, options); + regex = new System.Text.RegularExpressions.Regex (filter, options); } catch (Exception e) { IdeApp.Workbench.StatusBar.ShowError (e.Message); this.searchEntryFilter.Entry.ModifyBase (StateType.Normal, errorColor); @@ -1110,7 +1094,7 @@ namespace MonoDevelop.Gettext { public override bool EntryFails (CatalogEntry entry) { - foreach (System.Text.RegularExpressions.Match match in Regex.Matches (entry.String, @"\{.\}", RegexOptions.None)) { + foreach (System.Text.RegularExpressions.Match match in System.Text.RegularExpressions.Regex.Matches (entry.String, @"\{.\}", RegexOptions.None)) { if (!entry.GetTranslation (0).Contains (match.Value)) return true; } @@ -1119,7 +1103,7 @@ namespace MonoDevelop.Gettext public override string FailReason (CatalogEntry entry) { - foreach (System.Text.RegularExpressions.Match match in Regex.Matches (entry.String, @"\{.\}", RegexOptions.None)) { + foreach (System.Text.RegularExpressions.Match match in System.Text.RegularExpressions.Regex.Matches (entry.String, @"\{.\}", RegexOptions.None)) { if (!entry.GetTranslation (0).Contains (match.Value)) return GettextCatalog.GetString ("Original string '{0}' contains '{1}', translation doesn't.", entry.String, match.Value); } @@ -1223,9 +1207,9 @@ namespace MonoDevelop.Gettext { widget.inUndoOperation = true; widget.SelectEntry (Entry); - Mono.TextEditor.TextEditor textView = widget.GetTextView (Index); + var textView = widget.GetTextView (Index); if (textView != null) - textView.Document.Text = OldText; + textView.Text = OldText; widget.inUndoOperation = false; } @@ -1233,9 +1217,9 @@ namespace MonoDevelop.Gettext { widget.inUndoOperation = true; widget.SelectEntry (Entry); - Mono.TextEditor.TextEditor textView = widget.GetTextView (Index); + var textView = widget.GetTextView (Index); if (textView != null) - textView.Document.Text = Text; + textView.Text = Text; widget.inUndoOperation = false; } } |