Merge lp://staging/~alexlauni/do/no-repo into lp://staging/do
- no-repo
- Merge into trunk
Proposed by
Alex Launi
Status: | Merged |
---|---|
Merged at revision: | not available |
Proposed branch: | lp://staging/~alexlauni/do/no-repo |
Merge into: | lp://staging/do |
Diff against target: | None lines |
To merge this branch: | bzr merge lp://staging/~alexlauni/do/no-repo |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jason Smith (community) | Approve | ||
Review via email: mp+5772@code.staging.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Alex Launi (alexlauni) wrote : | # |
Revision history for this message
Jason Smith (jassmith) wrote : | # |
The XmlTextReader needs to be disposed
This is not too friendly to translators:
string errorMessage = Catalog.GetString ("<b><span size=\"
use:
string errorMessage = "<b><span size=\"large\">" + Catalog.GetString ("There was an error installing the selected ") + "{0}</span></b>";
Optionally:
LINQ-ify EnableDisabledP
review:
Approve
- 1118. By Alex Launi
-
wrap XmlReader in a using block
- 1119. By Alex Launi
-
some more linqification in InstallLocalPlugins
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'Do.Universe/Do.Universe.mdp' | |||
2 | --- Do.Universe/Do.Universe.mdp 2009-01-27 03:23:24 +0000 | |||
3 | +++ Do.Universe/Do.Universe.mdp 2009-04-21 01:01:54 +0000 | |||
4 | @@ -49,6 +49,5 @@ | |||
5 | 49 | <ProjectReference type="Gac" localcopy="True" refto="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> | 49 | <ProjectReference type="Gac" localcopy="True" refto="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> |
6 | 50 | <ProjectReference type="Gac" localcopy="True" refto="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> | 50 | <ProjectReference type="Gac" localcopy="True" refto="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> |
7 | 51 | <ProjectReference type="Gac" localcopy="True" refto="gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> | 51 | <ProjectReference type="Gac" localcopy="True" refto="gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> |
8 | 52 | <ProjectReference type="Gac" localcopy="True" refto="Do.Platform, Version=0.8.0.0, Culture=neutral, PublicKeyToken=null" /> | ||
9 | 53 | </References> | 52 | </References> |
10 | 54 | </Project> | 53 | </Project> |
11 | 55 | \ No newline at end of file | 54 | \ No newline at end of file |
12 | 56 | 55 | ||
13 | === added file 'Do/Do.addins' | |||
14 | --- Do/Do.addins 1970-01-01 00:00:00 +0000 | |||
15 | +++ Do/Do.addins 2009-03-31 23:04:25 +0000 | |||
16 | @@ -0,0 +1,3 @@ | |||
17 | 1 | <Addins> | ||
18 | 2 | <Directory include-subdirs="true">./plugins</Directory> | ||
19 | 3 | </Addins> | ||
20 | 0 | 4 | ||
21 | === modified file 'Do/Do.mdp' | |||
22 | --- Do/Do.mdp 2009-04-18 03:12:46 +0000 | |||
23 | +++ Do/Do.mdp 2009-04-21 22:18:57 +0000 | |||
24 | @@ -101,6 +101,7 @@ | |||
25 | 101 | <ProjectReference type="Project" localcopy="True" refto="Do.Interface.Linux" /> | 101 | <ProjectReference type="Project" localcopy="True" refto="Do.Interface.Linux" /> |
26 | 102 | <ProjectReference type="Project" localcopy="True" refto="Do.Universe" /> | 102 | <ProjectReference type="Project" localcopy="True" refto="Do.Universe" /> |
27 | 103 | <ProjectReference type="Gac" localcopy="True" refto="glib-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> | 103 | <ProjectReference type="Gac" localcopy="True" refto="glib-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> |
28 | 104 | <ProjectReference type="Gac" localcopy="True" refto="System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> | ||
29 | 104 | </References> | 105 | </References> |
30 | 105 | <LanguageParameters ApplicationIcon="../../../../../jason/do/trunk-merge/Do" ctype="CSharpProjectParameters" /> | 106 | <LanguageParameters ApplicationIcon="../../../../../jason/do/trunk-merge/Do" ctype="CSharpProjectParameters" /> |
31 | 106 | <Deployment.LinuxDeployData scriptName="gnome-do" /> | 107 | <Deployment.LinuxDeployData scriptName="gnome-do" /> |
32 | 107 | 108 | ||
33 | === modified file 'Do/Makefile.am' | |||
34 | --- Do/Makefile.am 2009-03-22 05:41:46 +0000 | |||
35 | +++ Do/Makefile.am 2009-04-21 22:18:57 +0000 | |||
36 | @@ -88,7 +88,8 @@ | |||
37 | 88 | $(MONO_ADDINS_SETUP_LIBS) \ | 88 | $(MONO_ADDINS_SETUP_LIBS) \ |
38 | 89 | $(NUNIT_LIBS) \ | 89 | $(NUNIT_LIBS) \ |
39 | 90 | System \ | 90 | System \ |
41 | 91 | System.Core | 91 | System.Core \ |
42 | 92 | System.Xml | ||
43 | 92 | 93 | ||
44 | 93 | PROJECT_REFERENCES = \ | 94 | PROJECT_REFERENCES = \ |
45 | 94 | Do.Universe \ | 95 | Do.Universe \ |
46 | @@ -103,7 +104,7 @@ | |||
47 | 103 | CLEANFILES += Do.exe.config gnome-do | 104 | CLEANFILES += Do.exe.config gnome-do |
48 | 104 | EXTRA_DIST += Do.exe.config.in gnome-do.in | 105 | EXTRA_DIST += Do.exe.config.in gnome-do.in |
49 | 105 | 106 | ||
51 | 106 | module_DATA += Do.exe.config | 107 | module_DATA += Do.exe.config Do.addins |
52 | 107 | bin_SCRIPTS = gnome-do | 108 | bin_SCRIPTS = gnome-do |
53 | 108 | 109 | ||
54 | 109 | MCS_FLAGS += -unsafe | 110 | MCS_FLAGS += -unsafe |
55 | 110 | 111 | ||
56 | === modified file 'Do/gtk-gui/gui.stetic' | |||
57 | --- Do/gtk-gui/gui.stetic 2009-03-06 07:14:21 +0000 | |||
58 | +++ Do/gtk-gui/gui.stetic 2009-04-22 02:17:30 +0000 | |||
59 | @@ -5,7 +5,7 @@ | |||
60 | 5 | <target-gtk-version>2.12</target-gtk-version> | 5 | <target-gtk-version>2.12</target-gtk-version> |
61 | 6 | </configuration> | 6 | </configuration> |
62 | 7 | <import> | 7 | <import> |
64 | 8 | <widget-library name="Mono.Addins.Gui, Version=0.3.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" /> | 8 | <widget-library name="Mono.Addins.Gui, Version=0.4.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" /> |
65 | 9 | <widget-library name="../bin/Debug/Do.exe" internal="true" /> | 9 | <widget-library name="../bin/Debug/Do.exe" internal="true" /> |
66 | 10 | </import> | 10 | </import> |
67 | 11 | <widget class="Gtk.Window" id="Do.UI.PreferencesWindow" design-size="450 470"> | 11 | <widget class="Gtk.Window" id="Do.UI.PreferencesWindow" design-size="450 470"> |
68 | @@ -1011,7 +1011,7 @@ | |||
69 | 1011 | <child internal-child="VBox"> | 1011 | <child internal-child="VBox"> |
70 | 1012 | <widget class="Gtk.VBox" id="dialog1_VBox"> | 1012 | <widget class="Gtk.VBox" id="dialog1_VBox"> |
71 | 1013 | <property name="MemberName" /> | 1013 | <property name="MemberName" /> |
73 | 1014 | <property name="BorderWidth">5</property> | 1014 | <property name="BorderWidth">2</property> |
74 | 1015 | <child> | 1015 | <child> |
75 | 1016 | <widget class="Gtk.VBox" id="vbox2"> | 1016 | <widget class="Gtk.VBox" id="vbox2"> |
76 | 1017 | <property name="MemberName" /> | 1017 | <property name="MemberName" /> |
77 | @@ -1119,7 +1119,7 @@ | |||
78 | 1119 | <child internal-child="ActionArea"> | 1119 | <child internal-child="ActionArea"> |
79 | 1120 | <widget class="Gtk.HButtonBox" id="dialog1_ActionArea"> | 1120 | <widget class="Gtk.HButtonBox" id="dialog1_ActionArea"> |
80 | 1121 | <property name="MemberName" /> | 1121 | <property name="MemberName" /> |
82 | 1122 | <property name="Spacing">10</property> | 1122 | <property name="Spacing">6</property> |
83 | 1123 | <property name="BorderWidth">5</property> | 1123 | <property name="BorderWidth">5</property> |
84 | 1124 | <property name="Size">1</property> | 1124 | <property name="Size">1</property> |
85 | 1125 | <property name="LayoutStyle">End</property> | 1125 | <property name="LayoutStyle">End</property> |
86 | 1126 | 1126 | ||
87 | === modified file 'Do/gtk-gui/objects.xml' | |||
88 | --- Do/gtk-gui/objects.xml 2009-04-18 03:12:46 +0000 | |||
89 | +++ Do/gtk-gui/objects.xml 2009-04-21 22:18:57 +0000 | |||
90 | @@ -1,2 +1,14 @@ | |||
91 | 1 | <objects attr-sync="on"> | 1 | <objects attr-sync="on"> |
92 | 2 | <object type="Do.UI.KeybindingsPreferencesWidget" palette-category="Do" allow-children="false" base-type="Gtk.Bin"> | ||
93 | 3 | <itemgroups /> | ||
94 | 4 | <signals /> | ||
95 | 5 | </object> | ||
96 | 6 | <object type="Do.UI.GeneralPreferencesWidget" palette-category="Do" allow-children="false" base-type="Gtk.Bin"> | ||
97 | 7 | <itemgroups /> | ||
98 | 8 | <signals /> | ||
99 | 9 | </object> | ||
100 | 10 | <object type="Do.UI.ManagePluginsPreferencesWidget" palette-category="Do" allow-children="false" base-type="Gtk.Bin"> | ||
101 | 11 | <itemgroups /> | ||
102 | 12 | <signals /> | ||
103 | 13 | </object> | ||
104 | 2 | </objects> | 14 | </objects> |
105 | 3 | \ No newline at end of file | 15 | \ No newline at end of file |
106 | 4 | 16 | ||
107 | === modified file 'Do/src/Do.Core/Paths.cs' | |||
108 | --- Do/src/Do.Core/Paths.cs 2009-01-11 00:00:14 +0000 | |||
109 | +++ Do/src/Do.Core/Paths.cs 2009-04-22 02:51:50 +0000 | |||
110 | @@ -29,50 +29,22 @@ | |||
111 | 29 | 29 | ||
112 | 30 | internal static class Paths | 30 | internal static class Paths |
113 | 31 | { | 31 | { |
114 | 32 | const string PluginsDirectory = "plugins"; | ||
115 | 32 | const string ApplicationDirectory = "gnome-do"; | 33 | const string ApplicationDirectory = "gnome-do"; |
118 | 33 | const string PluginsDirectory = "plugins"; | 34 | const string DefaultAddinsDirectory = "addins"; |
117 | 34 | const string RepositoryIndicatorFile = "main.mrep"; | ||
119 | 35 | 35 | ||
120 | 36 | //// <value> | 36 | //// <value> |
121 | 37 | /// Directory where Do saves its Mono.Addins repository cache. | 37 | /// Directory where Do saves its Mono.Addins repository cache. |
122 | 38 | /// </value> | 38 | /// </value> |
123 | 39 | public static string UserPluginsDirectory { | 39 | public static string UserPluginsDirectory { |
124 | 40 | get { | 40 | get { |
158 | 41 | string userData = | 41 | string userData = Environment.GetFolderPath (Environment.SpecialFolder.LocalApplicationData); |
159 | 42 | Environment.GetFolderPath (Environment.SpecialFolder.LocalApplicationData); | 42 | return userData.Combine (ApplicationDirectory, PluginsDirectory); |
127 | 43 | string pluginDirectory | ||
128 | 44 | = string.Format ("{0}-{1}", PluginsDirectory, AssemblyInfo.DisplayVersion); | ||
129 | 45 | return userData.Combine (ApplicationDirectory, pluginDirectory); | ||
130 | 46 | } | ||
131 | 47 | } | ||
132 | 48 | |||
133 | 49 | //// <value> | ||
134 | 50 | /// Directories where Do looks for Mono.Addins repositories. These | ||
135 | 51 | /// directories exist and probably contain valid repositories. | ||
136 | 52 | /// </value> | ||
137 | 53 | public static IEnumerable<string> SystemPluginDirectories { | ||
138 | 54 | get { | ||
139 | 55 | foreach (string repository in MaybeSystemPluginDirectories) { | ||
140 | 56 | if (File.Exists (Path.Combine (repository, RepositoryIndicatorFile))) | ||
141 | 57 | yield return repository; | ||
142 | 58 | } | ||
143 | 59 | } | ||
144 | 60 | } | ||
145 | 61 | |||
146 | 62 | //// <value> | ||
147 | 63 | /// Directories where Do might look for Mono.Addins repositories; these | ||
148 | 64 | /// directories may not exist or may not be valid repositories. | ||
149 | 65 | /// </value> | ||
150 | 66 | static IEnumerable<string> MaybeSystemPluginDirectories { | ||
151 | 67 | get { | ||
152 | 68 | yield return AppDomain.CurrentDomain.BaseDirectory.Combine (PluginsDirectory); | ||
153 | 69 | |||
154 | 70 | string systemData = | ||
155 | 71 | Environment.GetFolderPath (Environment.SpecialFolder.CommonApplicationData); | ||
156 | 72 | yield return systemData.Combine (ApplicationDirectory, PluginsDirectory); | ||
157 | 73 | yield return "/usr/local/share".Combine (ApplicationDirectory, PluginsDirectory); | ||
160 | 74 | } | 43 | } |
161 | 75 | } | 44 | } |
162 | 76 | 45 | ||
163 | 46 | public static string UserAddinInstallationDirectory { | ||
164 | 47 | get { return UserPluginsDirectory.Combine (DefaultAddinsDirectory); } | ||
165 | 48 | } | ||
166 | 77 | } | 49 | } |
167 | 78 | } | 50 | } |
168 | 79 | 51 | ||
169 | === modified file 'Do/src/Do.Core/PluginManager.cs' | |||
170 | --- Do/src/Do.Core/PluginManager.cs 2009-01-18 19:59:39 +0000 | |||
171 | +++ Do/src/Do.Core/PluginManager.cs 2009-04-22 02:17:30 +0000 | |||
172 | @@ -20,6 +20,7 @@ | |||
173 | 20 | 20 | ||
174 | 21 | using System; | 21 | using System; |
175 | 22 | using System.IO; | 22 | using System.IO; |
176 | 23 | using System.Xml; | ||
177 | 23 | using System.Linq; | 24 | using System.Linq; |
178 | 24 | using System.Collections.Generic; | 25 | using System.Collections.Generic; |
179 | 25 | 26 | ||
180 | @@ -54,25 +55,28 @@ | |||
181 | 54 | new CommunityAddinClassifier (), | 55 | new CommunityAddinClassifier (), |
182 | 55 | new GreedyAddinClassifier (), | 56 | new GreedyAddinClassifier (), |
183 | 56 | }; | 57 | }; |
185 | 57 | 58 | ||
186 | 58 | /// <summary> | 59 | /// <summary> |
187 | 59 | /// Performs plugin system initialization. Should be called before this | 60 | /// Performs plugin system initialization. Should be called before this |
188 | 60 | /// class or any Mono.Addins class is used. The ordering is very delicate. | 61 | /// class or any Mono.Addins class is used. The ordering is very delicate. |
189 | 61 | /// </summary> | 62 | /// </summary> |
190 | 62 | public static void Initialize () | 63 | public static void Initialize () |
191 | 63 | { | 64 | { |
192 | 65 | IEnumerable<string> savedPlugins = PluginsEnabledBeforeLoad (); | ||
193 | 66 | |||
194 | 64 | // Initialize Mono.Addins. | 67 | // Initialize Mono.Addins. |
195 | 65 | AddinManager.Initialize (Paths.UserPluginsDirectory); | 68 | AddinManager.Initialize (Paths.UserPluginsDirectory); |
206 | 66 | 69 | // This is a workaround for a Mono.Addins bug where updated addins will get | |
207 | 67 | // Register repositories. | 70 | // disabled on update. We save the currently enabled addins, update, then |
208 | 68 | SetupService setup = new SetupService (AddinManager.Registry); | 71 | // reenable them with the Id of the new version. It's a bit hackish but lluis |
209 | 69 | foreach (string path in Paths.SystemPluginDirectories) { | 72 | // said it's a reasonable approach until that bug is fixed |
210 | 70 | string url = "file://" + path; | 73 | // https://bugzilla.novell.com/show_bug.cgi?id=490302 |
211 | 71 | if (!setup.Repositories.ContainsRepository (url)) { | 74 | if (CorePreferences.PeekDebug) |
212 | 72 | setup.Repositories.RegisterRepository (null, url, false); | 75 | AddinManager.Registry.Rebuild (null); |
213 | 73 | } | 76 | else |
214 | 74 | } | 77 | AddinManager.Registry.Update (null); |
215 | 75 | 78 | EnableDisabledPlugins (savedPlugins); | |
216 | 79 | |||
217 | 76 | // Initialize services before addins that may use them are loaded. | 80 | // Initialize services before addins that may use them are loaded. |
218 | 77 | Services.Initialize (); | 81 | Services.Initialize (); |
219 | 78 | InterfaceManager.Initialize (); | 82 | InterfaceManager.Initialize (); |
220 | @@ -80,8 +84,24 @@ | |||
221 | 80 | // Now allow loading of non-services. | 84 | // Now allow loading of non-services. |
222 | 81 | foreach (string path in ExtensionPaths) | 85 | foreach (string path in ExtensionPaths) |
223 | 82 | AddinManager.AddExtensionNodeHandler (path, OnPluginChanged); | 86 | AddinManager.AddExtensionNodeHandler (path, OnPluginChanged); |
226 | 83 | 87 | } | |
227 | 84 | InstallLocalPlugins (setup); | 88 | |
228 | 89 | public static void InstallLocalPlugins () | ||
229 | 90 | { | ||
230 | 91 | string [] manual; | ||
231 | 92 | IEnumerable<string> saved; | ||
232 | 93 | |||
233 | 94 | manual = Directory.GetFiles (Paths.UserAddinInstallationDirectory, "*.dll"); | ||
234 | 95 | for (int i = 0; i < manual.Length; i++) { | ||
235 | 96 | manual [i] = Path.GetFileName (manual [i]); | ||
236 | 97 | } | ||
237 | 98 | |||
238 | 99 | AddinManager.Registry.Rebuild (null); | ||
239 | 100 | saved = AddinManager.Registry.GetAddins () | ||
240 | 101 | .Where (addin => manual.Contains (Path.GetFileName (addin.AddinFile))) | ||
241 | 102 | .Select (addin => addin.Id); | ||
242 | 103 | |||
243 | 104 | EnableDisabledPlugins (saved); | ||
244 | 85 | } | 105 | } |
245 | 86 | 106 | ||
246 | 87 | public static bool PluginClassifiesAs (AddinRepositoryEntry entry, string className) | 107 | public static bool PluginClassifiesAs (AddinRepositoryEntry entry, string className) |
247 | @@ -139,35 +159,67 @@ | |||
248 | 139 | public static IEnumerable<Act> Actions { | 159 | public static IEnumerable<Act> Actions { |
249 | 140 | get { return AddinManager.GetExtensionObjects ("/Do/Action").OfType<Act> (); } | 160 | get { return AddinManager.GetExtensionObjects ("/Do/Action").OfType<Act> (); } |
250 | 141 | } | 161 | } |
252 | 142 | 162 | ||
253 | 143 | /// <summary> | 163 | /// <summary> |
257 | 144 | /// Installs plugins that are located in the <see | 164 | /// Returns a list of the plugins that were enabled before Mono.Addins was initialised. |
258 | 145 | /// cref="Paths.UserPlugins"/> directory. This will build addins | 165 | /// this is read from config.xml. |
256 | 146 | /// (mpack files) and install them. | ||
259 | 147 | /// </summary> | 166 | /// </summary> |
275 | 148 | /// <param name="setup"> | 167 | /// <returns> |
276 | 149 | /// A <see cref="SetupService"/> | 168 | /// A <see cref="IEnumerable"/> of strings containing the versionless plugin id of all |
277 | 150 | /// </param> | 169 | /// enabled plugins. |
278 | 151 | public static void InstallLocalPlugins (SetupService setup) | 170 | /// </returns> |
279 | 152 | { | 171 | static IEnumerable<string> PluginsEnabledBeforeLoad () |
280 | 153 | IProgressStatus status = new ConsoleProgressStatus (false); | 172 | { |
281 | 154 | // GetFilePaths is like Directory.GetFiles but returned files have directory prefixed. | 173 | XmlTextReader reader; |
282 | 155 | Func<string, string, IEnumerable<string>> GetFilePaths = (dir, pattern) => | 174 | List<string> plugins; |
283 | 156 | Directory.GetFiles (dir, pattern).Select (f => Path.Combine (dir, f)); | 175 | |
284 | 157 | 176 | plugins = new List<string> (); | |
285 | 158 | // Create mpack (addin packages) out of dlls. | 177 | |
286 | 159 | GetFilePaths (Paths.UserPluginsDirectory, "*.dll") | 178 | try { |
287 | 160 | .ForEach (path => setup.BuildPackage (status, Paths.UserPluginsDirectory, new[] { path })) | 179 | // set up the reader by loading file, telling it that whitespace doesn't matter, and the DTD is irrelevant |
288 | 161 | // We delete the dlls after creating mpacks so we don't delete any dlls prematurely. | 180 | reader = new XmlTextReader (Paths.UserPluginsDirectory.Combine ("addin-db-001", "config.xml")); |
289 | 162 | .ForEach (File.Delete); | 181 | reader.XmlResolver = null; |
290 | 182 | reader.WhitespaceHandling = WhitespaceHandling.None; | ||
291 | 183 | reader.MoveToContent (); | ||
292 | 184 | |||
293 | 185 | if (string.IsNullOrEmpty (reader.Name)) | ||
294 | 186 | return Enumerable.Empty<string> (); | ||
295 | 187 | |||
296 | 188 | while (reader.Read ()) { | ||
297 | 189 | string id; | ||
298 | 190 | if (reader.NodeType != XmlNodeType.Element || !reader.HasAttributes) | ||
299 | 191 | continue; | ||
300 | 192 | |||
301 | 193 | reader.MoveToAttribute ("id"); | ||
302 | 194 | id = AddinIdWithoutVersion (reader.Value); | ||
303 | 195 | |||
304 | 196 | if (string.IsNullOrEmpty (id)) | ||
305 | 197 | continue; | ||
306 | 198 | |||
307 | 199 | reader.MoveToAttribute ("enabled"); | ||
308 | 200 | |||
309 | 201 | if (Boolean.Parse (reader.Value)) | ||
310 | 202 | plugins.Add (id); | ||
311 | 203 | } | ||
312 | 204 | } catch (FileNotFoundException e) { | ||
313 | 205 | Log.Debug ("Could not find locate Mono.Addins config.xml: {0}", e.Message); | ||
314 | 206 | } catch (XmlException e) { | ||
315 | 207 | Log.Error ("Error while parsing Mono.Addins config.xml: {0}", e.Message); | ||
316 | 208 | Log.Debug (e.StackTrace); | ||
317 | 209 | } | ||
318 | 210 | |||
319 | 211 | return plugins; | ||
320 | 212 | } | ||
321 | 213 | |||
322 | 214 | static void EnableDisabledPlugins (IEnumerable<string> savedPlugins) | ||
323 | 215 | { | ||
324 | 216 | foreach (Addin addin in AddinManager.Registry.GetAddins ()) { | ||
325 | 217 | string id = addin.Id; | ||
326 | 218 | if (!AddinManager.Registry.IsAddinEnabled (id) && savedPlugins.Any (name => id.StartsWith (name))) | ||
327 | 219 | AddinManager.Registry.EnableAddin (id); | ||
328 | 220 | } | ||
329 | 221 | } | ||
330 | 163 | 222 | ||
331 | 164 | // Install each mpack file, deleting each file when finished installing it. | ||
332 | 165 | foreach (string path in GetFilePaths (Paths.UserPluginsDirectory, "*.mpack")) { | ||
333 | 166 | setup.Install (status, new[] { path }); | ||
334 | 167 | File.Delete (path); | ||
335 | 168 | } | ||
336 | 169 | } | ||
337 | 170 | |||
338 | 171 | static void OnPluginChanged (object sender, ExtensionNodeEventArgs args) | 223 | static void OnPluginChanged (object sender, ExtensionNodeEventArgs args) |
339 | 172 | { | 224 | { |
340 | 173 | TypeExtensionNode node = args.ExtensionNode as TypeExtensionNode; | 225 | TypeExtensionNode node = args.ExtensionNode as TypeExtensionNode; |
341 | @@ -244,5 +296,10 @@ | |||
342 | 244 | { | 296 | { |
343 | 245 | return ObjectsForAddin<IConfigurable> (id); | 297 | return ObjectsForAddin<IConfigurable> (id); |
344 | 246 | } | 298 | } |
345 | 299 | |||
346 | 300 | static string AddinIdWithoutVersion (string id) | ||
347 | 301 | { | ||
348 | 302 | return id.Substring (0, id.IndexOf (',')); | ||
349 | 303 | } | ||
350 | 247 | } | 304 | } |
351 | 248 | } | 305 | } |
352 | 249 | 306 | ||
353 | === modified file 'Do/src/Do.UI/ManagePluginsPreferencesWidget.cs' | |||
354 | --- Do/src/Do.UI/ManagePluginsPreferencesWidget.cs 2009-02-19 03:09:17 +0000 | |||
355 | +++ Do/src/Do.UI/ManagePluginsPreferencesWidget.cs 2009-04-22 02:17:30 +0000 | |||
356 | @@ -25,10 +25,9 @@ | |||
357 | 25 | using System.Collections.Generic; | 25 | using System.Collections.Generic; |
358 | 26 | 26 | ||
359 | 27 | using Gtk; | 27 | using Gtk; |
360 | 28 | using Mono.Unix; | ||
361 | 29 | using Mono.Addins; | 28 | using Mono.Addins; |
362 | 30 | using Mono.Addins.Gui; | ||
363 | 31 | using Mono.Addins.Setup; | 29 | using Mono.Addins.Setup; |
364 | 30 | using Mono.Unix; | ||
365 | 32 | 31 | ||
366 | 33 | using Do; | 32 | using Do; |
367 | 34 | using Do.Core; | 33 | using Do.Core; |
368 | @@ -44,8 +43,7 @@ | |||
369 | 44 | public partial class ManagePluginsPreferencesWidget : Bin, IConfigurable | 43 | public partial class ManagePluginsPreferencesWidget : Bin, IConfigurable |
370 | 45 | { | 44 | { |
371 | 46 | 45 | ||
374 | 47 | const string PluginWikiPageFormat = | 46 | const string PluginWikiPageFormat = "http://do.davebsd.com/wiki/index.php?title={0}_Plugin"; |
373 | 48 | "http://do.davebsd.com/wiki/index.php?title={0}_Plugin"; | ||
375 | 49 | 47 | ||
376 | 50 | PluginNodeView nview; | 48 | PluginNodeView nview; |
377 | 51 | SearchEntry search_entry; | 49 | SearchEntry search_entry; |
378 | @@ -92,44 +90,56 @@ | |||
379 | 92 | search_entry.Show(); | 90 | search_entry.Show(); |
380 | 93 | search_entry.Ready = true; | 91 | search_entry.Ready = true; |
381 | 94 | 92 | ||
384 | 95 | hbox1.PackStart (search_entry,true,true,0); | 93 | hbox1.PackStart (search_entry, true, true, 0); |
385 | 96 | hbox1.ShowAll(); | 94 | hbox1.ShowAll (); |
386 | 97 | 95 | ||
390 | 98 | Services.Application.RunOnMainThread (() => | 96 | Services.Application.RunOnMainThread (() => search_entry.InnerEntry.GrabFocus ()); |
388 | 99 | search_entry.InnerEntry.GrabFocus () | ||
389 | 100 | ); | ||
391 | 101 | } | 97 | } |
392 | 102 | 98 | ||
393 | 103 | protected void OnDragDataReceived (object sender, DragDataReceivedArgs args) | 99 | protected void OnDragDataReceived (object sender, DragDataReceivedArgs args) |
394 | 104 | { | 100 | { |
396 | 105 | string data = Encoding.UTF8.GetString (args.SelectionData.Data); | 101 | string data; |
397 | 102 | string [] uriList; | ||
398 | 103 | List<string> errors; | ||
399 | 104 | |||
400 | 105 | data = Encoding.UTF8.GetString (args.SelectionData.Data); | ||
401 | 106 | // Sometimes we get a null at the end, and it crashes us. | 106 | // Sometimes we get a null at the end, and it crashes us. |
402 | 107 | data = data.TrimEnd ('\0'); | 107 | data = data.TrimEnd ('\0'); |
403 | 108 | 108 | ||
406 | 109 | string [] uriList = Regex.Split (data, "\r\n"); | 109 | errors = new List<string> (); |
407 | 110 | List<string> errors = new List<string> (); | 110 | uriList = Regex.Split (data, "\r\n"); |
408 | 111 | |||
409 | 111 | foreach (string uri in uriList) { | 112 | foreach (string uri in uriList) { |
412 | 112 | string file; | 113 | string file, path, filename; |
411 | 113 | string path; | ||
413 | 114 | 114 | ||
414 | 115 | if (string.IsNullOrEmpty (uri)) | ||
415 | 116 | continue; | ||
416 | 117 | |||
417 | 115 | try { | 118 | try { |
420 | 116 | file = uri.Remove (0, 7); | 119 | file = uri.Remove (0, 7); // 7 is the length of file:// |
421 | 117 | string fileName = System.IO.Path.GetFileName (file); | 120 | // I have to use System.IO here due to a Gtk namespace conflict |
422 | 121 | filename = System.IO.Path.GetFileName (file); | ||
423 | 122 | |||
424 | 118 | if (!file.EndsWith (".dll")) { | 123 | if (!file.EndsWith (".dll")) { |
426 | 119 | errors.Add (fileName); | 124 | errors.Add (filename); |
427 | 120 | continue; | 125 | continue; |
428 | 121 | } | 126 | } |
429 | 122 | 127 | ||
431 | 123 | path = Paths.UserPluginsDirectory.Combine (fileName); | 128 | if (!Directory.Exists (Paths.UserAddinInstallationDirectory)) |
432 | 129 | Directory.CreateDirectory (Paths.UserAddinInstallationDirectory); | ||
433 | 130 | |||
434 | 131 | path = Paths.UserAddinInstallationDirectory.Combine (filename); | ||
435 | 124 | File.Copy (file, path, true); | 132 | File.Copy (file, path, true); |
437 | 125 | } catch { } | 133 | |
438 | 134 | if (errors.Count > 0) | ||
439 | 135 | new PluginErrorDialog (errors.ToArray ()); | ||
440 | 136 | |||
441 | 137 | PluginManager.InstallLocalPlugins (); | ||
442 | 138 | } catch (Exception e) { | ||
443 | 139 | Log<ManagePluginsPreferencesWidget>.Error ("An unexpected error occurred installing your plugin"); | ||
444 | 140 | Log<ManagePluginsPreferencesWidget>.Debug ("{0}\n{1}", e.Message, e.StackTrace); | ||
445 | 141 | } | ||
446 | 126 | } | 142 | } |
447 | 127 | |||
448 | 128 | if (errors.Count > 0) | ||
449 | 129 | new PluginErrorDialog (errors.ToArray ()); | ||
450 | 130 | |||
451 | 131 | SetupService setup = new SetupService (AddinManager.Registry); | ||
452 | 132 | PluginManager.InstallLocalPlugins (setup); | ||
453 | 133 | } | 143 | } |
454 | 134 | 144 | ||
455 | 135 | public Bin GetConfiguration () | 145 | public Bin GetConfiguration () |
456 | 136 | 146 | ||
457 | === modified file 'Do/src/Do.UI/PluginErrorDialog.cs' | |||
458 | --- Do/src/Do.UI/PluginErrorDialog.cs 2008-10-25 03:53:44 +0000 | |||
459 | +++ Do/src/Do.UI/PluginErrorDialog.cs 2009-04-22 02:17:30 +0000 | |||
460 | @@ -29,12 +29,12 @@ | |||
461 | 29 | 29 | ||
462 | 30 | public PluginErrorDialog(string[] files) | 30 | public PluginErrorDialog(string[] files) |
463 | 31 | { | 31 | { |
464 | 32 | string errorMessage = Catalog.GetString ("<b><span size=\"large\">There was an error installing the selected {0}</span></b>"); | ||
465 | 33 | |||
466 | 32 | this.Build(); | 34 | this.Build(); |
467 | 33 | 35 | ||
472 | 34 | if (files.Length > 1) | 36 | header_lbl.Markup = Catalog.GetPluralString (string.Format (errorMessage, Catalog.GetString ("plugin")), |
473 | 35 | header_lbl.Markup = Catalog.GetString ("<b><span size=\"large\">There was an error installing the selected plugins</span></b>"); | 37 | string.Format (errorMessage, Catalog.GetString ("plugins")), files.Length); |
470 | 36 | else | ||
471 | 37 | header_lbl.Markup = Catalog.GetString ("<b><span size=\"large\">There was an error installing the selected plugin</span></b>"); | ||
474 | 38 | 38 | ||
475 | 39 | string errors = ""; | 39 | string errors = ""; |
476 | 40 | for (int i = 0; i < files.Length; i++) { | 40 | for (int i = 0; i < files.Length; i++) { |
477 | 41 | 41 | ||
478 | === modified file 'Do/src/Do.UI/PreferencesWindow.cs' | |||
479 | --- Do/src/Do.UI/PreferencesWindow.cs 2009-01-05 22:19:09 +0000 | |||
480 | +++ Do/src/Do.UI/PreferencesWindow.cs 2009-04-22 02:17:30 +0000 | |||
481 | @@ -51,9 +51,7 @@ | |||
482 | 51 | 51 | ||
483 | 52 | btn_close.IsFocus = true; | 52 | btn_close.IsFocus = true; |
484 | 53 | 53 | ||
488 | 54 | TargetEntry [] targets = { | 54 | TargetEntry [] targets = { new TargetEntry ("text/uri-list", 0, 0) }; |
486 | 55 | new TargetEntry ("text/uri-list", 0, 0), | ||
487 | 56 | }; | ||
489 | 57 | Drag.DestSet (this, DestDefaults.All, targets, Gdk.DragAction.Copy); | 55 | Drag.DestSet (this, DestDefaults.All, targets, Gdk.DragAction.Copy); |
490 | 58 | 56 | ||
491 | 59 | // Add notebook pages. | 57 | // Add notebook pages. |
the right branch