Author: mkrueger
Date: 2007-08-08 04:38:30 -0400 (Wed, 08 Aug 2007)
New Revision: 83641

Modified:
   trunk/monodevelop/Extras/MonoDevelop.Gettext/ChangeLog
   
trunk/monodevelop/Extras/MonoDevelop.Gettext/MonoDevelop.Gettext.NodeBuilders/TranslationProjectNodeBuilder.cs
   
trunk/monodevelop/Extras/MonoDevelop.Gettext/MonoDevelop.Gettext/TranslationProject.cs
   
trunk/monodevelop/Extras/MonoDevelop.Gettext/MonoDevelop.Gettext/TranslationProjectOptionsDialog.cs
Log:
* MonoDevelop.Gettext.NodeBuilders/TranslationProjectNodeBuilder.cs,
  MonoDevelop.Gettext/TranslationProjectOptionsDialog.cs,
  MonoDevelop.Gettext/TranslationProject.cs: Fixed 82335: Gettext
  addin: can't choose which projects to translate.

Modified: trunk/monodevelop/Extras/MonoDevelop.Gettext/ChangeLog
===================================================================
--- trunk/monodevelop/Extras/MonoDevelop.Gettext/ChangeLog      2007-08-08 
08:04:57 UTC (rev 83640)
+++ trunk/monodevelop/Extras/MonoDevelop.Gettext/ChangeLog      2007-08-08 
08:38:30 UTC (rev 83641)
@@ -1,3 +1,10 @@
+2007-08-08  Mike Krüger <[EMAIL PROTECTED]> 
+
+       * MonoDevelop.Gettext.NodeBuilders/TranslationProjectNodeBuilder.cs,
+         MonoDevelop.Gettext/TranslationProjectOptionsDialog.cs,
+         MonoDevelop.Gettext/TranslationProject.cs: Fixed 82335: Gettext
+         addin: can't choose which projects to translate.
+
 2007-08-06  Mike Krüger <[EMAIL PROTECTED]> 
 
        * MonoDevelop.Gettext.Editor/POEditorWidget.cs: added bugfix from

Modified: 
trunk/monodevelop/Extras/MonoDevelop.Gettext/MonoDevelop.Gettext/TranslationProject.cs
===================================================================
--- 
trunk/monodevelop/Extras/MonoDevelop.Gettext/MonoDevelop.Gettext/TranslationProject.cs
      2007-08-08 08:04:57 UTC (rev 83640)
+++ 
trunk/monodevelop/Extras/MonoDevelop.Gettext/MonoDevelop.Gettext/TranslationProject.cs
      2007-08-08 08:38:30 UTC (rev 83641)
@@ -41,22 +41,51 @@
 using MonoDevelop.Deployment;
 
 namespace MonoDevelop.Gettext
-{
+{      
        public class TranslationProject : CombineEntry, IDeployable
        {
                [ItemProperty]
                List<Translation> translations = new List<Translation> ();
                
+               [ItemProperty]
+               List<TranslationProjectInformation> projectInformations = new 
List<TranslationProjectInformation> ();
+               
                public ReadOnlyCollection<Translation> Translations {
                        get { return translations.AsReadOnly (); }
                }
                
+               public ReadOnlyCollection<TranslationProjectInformation> 
TranslationProjectInformations {
+                       get { return projectInformations.AsReadOnly (); }
+               }
+               
                public TranslationProject ()
                {
                        this.NeedsBuilding = true;
                        isDirty = true;
                }
                
+               public TranslationProjectInformation GetProjectInformation 
(CombineEntry entry, bool force)
+               {
+                       foreach (TranslationProjectInformation info in 
this.projectInformations) {
+                               if (info.ProjectName == entry.Name)
+                                       return info;
+                       }
+                       if (force) {
+                               TranslationProjectInformation newInfo = new 
TranslationProjectInformation (entry.Name);
+                               this.projectInformations.Add (newInfo);
+                               return newInfo;
+                       }
+                       return null;
+               }
+               
+               public bool IsIncluded (CombineEntry entry)
+               {
+                       TranslationProjectInformation info = 
GetProjectInformation (entry, false);
+                       if (info != null)
+                               return info.IsIncluded;
+                       return true;
+               }
+               
                public override void InitializeFromTemplate (XmlElement 
template)
                {
                        foreach (XmlNode node in template.ChildNodes) {
@@ -397,4 +426,39 @@
                {
                }
        }
+       
+       public class TranslationProjectInformation
+       {
+               [ItemProperty]
+               string projectName;
+               
+               [ItemProperty]
+               bool isIncluded;
+               
+               [ItemProperty]
+               List<string> excludedFiles = new List<string> ();
+               
+               public string ProjectName {
+                       get { return projectName; }
+                       set { projectName = value; }
+               }
+               
+               public bool IsIncluded {
+                       get { return isIncluded; }
+                       set { isIncluded = value; }
+               }
+               
+               public ReadOnlyCollection<string> ExcludedFiles {
+                       get { return excludedFiles.AsReadOnly (); }
+               }
+               
+               public TranslationProjectInformation ()
+               {
+               }
+               
+               public TranslationProjectInformation (string projectName)
+               {
+                       this.projectName = projectName;
+               }
+       }       
 }

Modified: 
trunk/monodevelop/Extras/MonoDevelop.Gettext/MonoDevelop.Gettext/TranslationProjectOptionsDialog.cs
===================================================================
--- 
trunk/monodevelop/Extras/MonoDevelop.Gettext/MonoDevelop.Gettext/TranslationProjectOptionsDialog.cs
 2007-08-08 08:04:57 UTC (rev 83640)
+++ 
trunk/monodevelop/Extras/MonoDevelop.Gettext/MonoDevelop.Gettext/TranslationProjectOptionsDialog.cs
 2007-08-08 08:38:30 UTC (rev 83641)
@@ -27,6 +27,9 @@
 //
 
 using System;
+using Gtk;
+using MonoDevelop.Projects;
+using MonoDevelop.Ide.Gui;
 
 namespace MonoDevelop.Gettext
 {
@@ -67,8 +70,80 @@
                        this.buttonCancel.Clicked += delegate {
                                this.Destroy ();
                        };
+                       
+                       store = new TreeStore (typeof(string), typeof(bool), 
typeof(string), typeof(CombineEntry));
+                       treeviewProjectList.Model = store;
+                       treeviewProjectList.HeadersVisible = false;
+                       
+                       this.treeviewProjectList.AppendColumn ("", new 
CellRendererPixbuf (), "stock_id", 0);
+                       
+                       CellRendererToggle cellRendererToggle = new 
CellRendererToggle ();
+                       cellRendererToggle.Toggled += new ToggledHandler 
(ActiveToggled);
+                       cellRendererToggle.Activatable = true;
+                       this.treeviewProjectList.AppendColumn ("", 
cellRendererToggle, "active", 1);
+                       
+                       this.treeviewProjectList.AppendColumn ("", new 
CellRendererText (), "text", 2);
+                       
+                       FillTree (TreeIter.Zero, project.ParentCombine);
+                       
                }
                
+               void ActiveToggled (object sender, ToggledArgs e)
+               {
+                       TreeIter iter;
+                       if (store.GetIterFromString (out iter, e.Path)) {
+                               bool         isTogglod = (bool)store.GetValue 
(iter, 1);
+                               CombineEntry entry     = 
(CombineEntry)store.GetValue (iter, 3);
+                               if (entry is Project) {
+                                       TranslationProjectInformation info = 
project.GetProjectInformation (entry, true);
+                                       info.IsIncluded = !isTogglod;
+                                       store.SetValue (iter, 1, !isTogglod);
+                               }
+                       }
+               }
+               
+               TreeStore store;
+               string GetIcon (CombineEntry entry)
+               {
+                       if (entry is Combine)
+                               return MonoDevelop.Core.Gui.Stock.CombineIcon;
+                       
+                       if (entry is Project)
+                               return 
IdeApp.Services.Icons.GetImageForProjectType (((Project)entry).ProjectType);
+                       
+                       return MonoDevelop.Core.Gui.Stock.SolutionIcon;
+               }
+               
+               bool IsIncluded (CombineEntry entry)
+               {
+                       if (entry is Combine) {
+                               foreach (CombineEntry childEntry in 
((Combine)entry).Entries)
+                                       if (!IsIncluded (childEntry))
+                                               return false;
+                               return true;
+                       }
+                       
+                       TranslationProjectInformation info = 
project.GetProjectInformation (entry, false);
+                       if (info != null)
+                               return info.IsIncluded;
+                       return true;
+               }
+                       
+               void FillTree (TreeIter iter, CombineEntry entry)
+               {
+                       TreeIter curIter;
+                       if (!iter.Equals (TreeIter.Zero)) {
+                               curIter = store.AppendValues (iter, GetIcon 
(entry), entry is Combine ? false : IsIncluded (entry), entry.Name, entry);
+                       } else {
+                               curIter = store.AppendValues (GetIcon (entry), 
entry is Combine ? false : IsIncluded (entry), entry.Name, entry);
+                       }
+                       if (entry is Combine) {
+                               foreach (CombineEntry childEntry in 
((Combine)entry).Entries)
+                                       if (!(childEntry is TranslationProject) 
&& (childEntry is Project || childEntry is Combine))
+                                               FillTree (curIter, childEntry);
+                       }
+               }
+               
                void UpdateInitString (object sender, EventArgs e)
                {
                        string path;

Modified: 
trunk/monodevelop/Extras/MonoDevelop.Gettext/MonoDevelop.Gettext.NodeBuilders/TranslationProjectNodeBuilder.cs
===================================================================
--- 
trunk/monodevelop/Extras/MonoDevelop.Gettext/MonoDevelop.Gettext.NodeBuilders/TranslationProjectNodeBuilder.cs
      2007-08-08 08:04:57 UTC (rev 83640)
+++ 
trunk/monodevelop/Extras/MonoDevelop.Gettext/MonoDevelop.Gettext.NodeBuilders/TranslationProjectNodeBuilder.cs
      2007-08-08 08:38:30 UTC (rev 83641)
@@ -140,7 +140,8 @@
                                if (project == null)
                                        return;
                                TranslationProjectOptionsDialog options = new 
TranslationProjectOptionsDialog (project);
-                               options.Show ();
+                               options.Run ();
+                               IdeApp.ProjectOperations.SaveCombine ();
                        }
                        
                        [CommandHandler (Commands.AddTranslation)]
@@ -178,12 +179,18 @@
                        {
                                using (IProgressMonitor monitor = 
IdeApp.Workbench.ProgressMonitors.GetBuildProgressMonitor ()) {
                                        int count = 0;
-                                       foreach (Project p in 
project.ParentCombine.GetAllProjects ()) 
+                                       foreach (Project p in 
project.ParentCombine.GetAllProjects ()) {
+                                               if (!project.IsIncluded (p))
+                                                       continue;
                                                count++;
+                                       }
                                        monitor.BeginTask 
(GettextCatalog.GetString ("Updating Translations "), count);
                                        
                                        foreach (Project p in 
project.ParentCombine.GetAllProjects ()) {
-                                               monitor.BeginStepTask 
(String.Format (GettextCatalog.GetString ("Scanning project {0}..."),  p.Name), 
1, 1);
+                                               if (!project.IsIncluded (p))
+                                                       continue;
+                                               monitor.Log.WriteLine 
(String.Format (GettextCatalog.GetString ("Scanning project {0}..."),  p.Name));
+                                               monitor.Step (1);
                                                foreach (ProjectFile file in 
p.ProjectFiles) {
                                                        
TranslationService.UpdateTranslation (project, file.FilePath, monitor);
                                                }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to