5 // David Makovský <yakeen@sannyas-on.net>
8 // Copyright (C) 2006 Novell, Inc (http://www.novell.com)
9 // Copyright (C) 2007 David Makovský
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 using System
.Collections
.Generic
;
35 using MonoDevelop
.Core
;
36 using MonoDevelop
.Ide
.Gui
;
38 namespace MonoDevelop
.Gettext
.Editor
40 internal class CatalogEditorView
: AbstractViewContent
43 POEditorWidget poEditorWidget
;
45 public CatalogEditorView (TranslationProject project
, string poFile
)
47 catalog
= new Catalog (project
);
48 poEditorWidget
= new POEditorWidget (project
);
49 catalog
.DirtyChanged
+= delegate (object sender
, EventArgs args
) {
50 IsDirty
= catalog
.IsDirty
;
51 if (sender
is CatalogEntry
)
52 this.poEditorWidget
.UpdateEntry (sender
as CatalogEntry
);
56 public override void Dispose ()
58 if (this.poEditorWidget
!= null) {
59 this.poEditorWidget
.Destroy ();
60 this.poEditorWidget
= null;
65 public override void Load (string fileName
)
67 // using (IProgressMonitor mon = IdeApp.Workbench.ProgressMonitors.GetLoadProgressMonitor (true)) {
68 catalog
.Load (null, fileName
);
70 poEditorWidget
.Catalog
= catalog
;
71 poEditorWidget
.POFileName
= fileName
;
72 poEditorWidget
.UpdateRules (System
.IO
.Path
.GetFileNameWithoutExtension (fileName
));
74 this.ContentName
= fileName
;
78 public override void Save (string fileName
)
80 OnBeforeSave (EventArgs
.Empty
);
81 catalog
.Save (fileName
);
82 ContentName
= fileName
;
86 public override void Save ()
88 Save (this.ContentName
);
91 public override Widget Control
93 get { return poEditorWidget; }
96 public override bool IsReadOnly
101 public override string TabPageLabel
103 get { return GettextCatalog.GetString ("Gettext Editor"); }