Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLluis Sanchez <llsan@microsoft.com>2019-02-18 11:21:38 +0300
committerLluis Sanchez <llsan@microsoft.com>2019-02-18 15:16:02 +0300
commitf8fd63c921752e49f1bf64e9eea667f8b57e9d47 (patch)
treee46f9ac98e014911ea562b656212008c96c4376e /main/src/addins/MonoDevelop.Gettext
parentf6af7e1b7349ad2c09b83487bc7e34949488dc86 (diff)
Implemented .po editor as document controller
Diffstat (limited to 'main/src/addins/MonoDevelop.Gettext')
-rw-r--r--main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.Editor/CatalogEditorView.cs69
-rw-r--r--main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.Editor/GettextEditorDisplayBinding.cs63
-rw-r--r--main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.addin.xml4
-rw-r--r--main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.csproj1
4 files changed, 29 insertions, 108 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 d33b7ec7be..b9d1b220f4 100644
--- a/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.Editor/CatalogEditorView.cs
+++ b/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.Editor/CatalogEditorView.cs
@@ -29,52 +29,56 @@
//
using System;
-using System.Collections.Generic;
-using Gtk;
-using Gdk;
using MonoDevelop.Components;
using MonoDevelop.Core;
-using MonoDevelop.Ide.Gui;
using MonoDevelop.Ide.Gui.Content;
using System.Threading.Tasks;
+using MonoDevelop.Ide.Gui.Documents;
+using MonoDevelop.Ide;
namespace MonoDevelop.Gettext.Editor
{
- class CatalogEditorView : ViewContent, IUndoHandler
+ [ExportFileDocumentController (FileExtension = ".po", Name = "Gettext Editor", CanUseAsDefault = true, InsertBefore = "DefaultDisplayBinding")]
+ class CatalogEditorView : FileDocumentController, IUndoHandler
{
Catalog catalog;
POEditorWidget poEditorWidget;
+ FilePath fileName;
- public CatalogEditorView (TranslationProject project, string poFile)
+ protected override Task OnInitialize (ModelDescriptor modelDescriptor, Properties status)
{
+ TabPageLabel = GettextCatalog.GetString ("Gettext Editor");
+ return base.OnInitialize (modelDescriptor, status);
+ }
+
+ protected override Control OnGetViewControl (DocumentViewContent view)
+ {
+ TranslationProject project = null;
+
+ if (IdeApp.IsInitialized) {
+ foreach (var tp in IdeApp.Workspace.GetAllItems<TranslationProject> ())
+ if (tp.BaseDirectory == FilePath.ParentDirectory)
+ project = tp;
+ }
+
catalog = new Catalog (project);
poEditorWidget = new POEditorWidget (project);
catalog.DirtyChanged += delegate (object sender, EventArgs args) {
- IsDirty = catalog.IsDirty;
+ HasUnsavedChanges = catalog.IsDirty;
};
- }
-
- public override Task Load (FileOpenInformation fileOpenInformation)
- {
- var fileName = fileOpenInformation.FileName;
-// using (IProgressMonitor mon = IdeApp.Workbench.ProgressMonitors.GetLoadProgressMonitor (true)) {
- catalog.Load (null, fileName);
-// }
+
+ catalog.Load (null, FilePath);
+
poEditorWidget.Catalog = catalog;
poEditorWidget.POFileName = fileName;
poEditorWidget.UpdateRules (System.IO.Path.GetFileNameWithoutExtension (fileName));
-
- this.ContentName = fileName;
- this.IsDirty = false;
- return Task.FromResult (true);
+ return poEditorWidget;
}
-
- public override Task Save (FileSaveInformation fileSaveInformation)
+
+ protected override Task OnSave ()
{
- catalog.Save (fileSaveInformation.FileName);
- ContentName = fileSaveInformation.FileName;
- IsDirty = false;
- return Task.FromResult (true);
+ catalog.Save (FilePath);
+ return Task.CompletedTask;
}
#region IUndoHandler implementation
@@ -105,20 +109,5 @@ namespace MonoDevelop.Gettext.Editor
}
}
#endregion
-
- public override Control Control
- {
- get { return poEditorWidget; }
- }
-
- public override bool IsReadOnly
- {
- get { return false; }
- }
-
- public override string TabPageLabel
- {
- get { return GettextCatalog.GetString ("Gettext Editor"); }
- }
}
}
diff --git a/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.Editor/GettextEditorDisplayBinding.cs b/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.Editor/GettextEditorDisplayBinding.cs
deleted file mode 100644
index 0f9d629cfd..0000000000
--- a/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.Editor/GettextEditorDisplayBinding.cs
+++ /dev/null
@@ -1,63 +0,0 @@
-//
-// GettextEditorDisplayBinding.cs
-//
-// Author:
-// David Makovský <yakeen@sannyas-on.net>
-//
-// Copyright (C) 2007 David Makovský
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.IO;
-using MonoDevelop.Core;
-using MonoDevelop.Ide;
-using MonoDevelop.Ide.Gui;
-using MonoDevelop.Ide.Codons;
-using MonoDevelop.Projects;
-
-namespace MonoDevelop.Gettext
-{
- class GettextEditorDisplayBinding : IViewDisplayBinding
- {
- public string Name {
- get { return GettextCatalog.GetString ("Gettext Editor"); }
- }
-
- public bool CanHandle (FilePath filePath, string mimeType, Project project)
- {
- return filePath.IsNotNull && filePath.HasExtension (".po");
- }
-
- public ViewContent CreateContent (FilePath filePath, string mimeType, Project project)
- {
- foreach (TranslationProject tp in IdeApp.Workspace.GetAllItems<TranslationProject> ())
- if (tp.BaseDirectory == Path.GetDirectoryName (filePath))
- return new Editor.CatalogEditorView (tp, filePath);
-
- return new Editor.CatalogEditorView (null, filePath);
- }
-
- public bool CanUseAsDefault {
- get { return true; }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.addin.xml b/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.addin.xml
index 318b6e59d7..7a628fc5e5 100644
--- a/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.addin.xml
+++ b/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.addin.xml
@@ -57,10 +57,6 @@
<FileFilter id = "PoFiles" _label = "PO Files" extensions = "*.po"/>
</Extension>
- <Extension path = "/MonoDevelop/Ide/DisplayBindings">
- <DisplayBinding id = "GettextEditor" insertbefore ="DefaultDisplayBinding" class = "MonoDevelop.Gettext.GettextEditorDisplayBinding"/>
- </Extension>
-
<Extension path = "/MonoDevelop/ProjectModel/SerializableClasses">
<DataType class = "MonoDevelop.Gettext.TranslationProject" />
<DataType class = "MonoDevelop.Gettext.TranslationProjectConfiguration" />
diff --git a/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.csproj b/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.csproj
index 83f11f2de1..b872fac144 100644
--- a/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.csproj
+++ b/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.csproj
@@ -71,7 +71,6 @@
<Compile Include="MonoDevelop.Gettext.Editor\CatalogHeadersWidget.cs" />
<Compile Include="Commands.cs" />
<Compile Include="MonoDevelop.Gettext.Translator\LanguageChooserDialog.cs" />
- <Compile Include="MonoDevelop.Gettext.Editor\GettextEditorDisplayBinding.cs" />
<Compile Include="MonoDevelop.Gettext\TranslationProject.cs" />
<Compile Include="MonoDevelop.Gettext\Translation.cs" />
<Compile Include="MonoDevelop.Gettext.NodeBuilders\TranslationProjectNodeBuilder.cs" />