~ubuntu-branches/debian/sid/f-spot/sid

« back to all changes in this revision

Viewing changes to lib/mono-addins/Mono.Addins.Gui/Mono.Addins.Gui/AddinInstallDialog.cs

  • Committer: Bazaar Package Importer
  • Author(s): Iain Lane
  • Date: 2010-05-17 11:59:58 UTC
  • mfrom: (2.4.6 sid)
  • Revision ID: james.westby@ubuntu.com-20100517115958-rplbws9ddda5ikcp
* New upstream release 0.6.2:
 + Stable release before starting large cleanup refactorings, mostly 
   usability, bug fixes and translations as well as some modernization.
   A large part of this comes from the Ubuntu one hundred papercuts effort.
 + Replaced the old slow slideshow code with new fast SlideShow
   (Gabriel Burt)
 + Wording changes for clarity (Edit Tag) (Jeffrey Finkelstein)
 + Fix version selection tooltip (Lorenzo Milesi)
 + Add gconf schema (Jeffrey Stedfast)
 + Added a border to filmstrip thumbnails (Matt Perry) (LP: #513036)
 + Fix display names of color profiles (Pascal de Bruijn)
 + Fix histogram colors on theme change (Paul Wellner Bou)
 + Always update ImageView adjustments when scaling.
   (Wojciech Dzierżanowski)
 + Correctly set attributes on copying (Yann Leprince)
 + Correct mnemonics in create tag dialog (Yves Kurz)
 + Provide sane defaults for image resize size (Yves Kurz)
 + Updates to the build system, including fixes for distcheck
   (Ruben Vermeersch)
 + Fix wording for duplicate hashing (Matt Perry)
 + Fix wording for imported tags tag (Ian Churcher)
 + Fix label alignment in preferences dialog (Pascal de Bruijn)
 + Add unique# and use it to handle our activation (Stephane Delcroix)
 + Stop bundling Mono.Addins (Stephane Delcroix)
 + Avoid leakage in straighten and softfocus editor (Stephane Delcroix)
 + Allow to copy files to clipboard (Stephane Delcroix)
 + Large number of color management related fixes (Stephane Delcroix)
 + Removed the Beagle plugin at the request of the openSUSE team
   (Ruben Vermeersch)
 + A pile of other cleanups and fixes (Ruben Vermeersch)
   - Including '"Import tags" category sounds like an action' (LP: #488784)
 + Two performance improvement patches for our database interaction
   (Michal Nánási)
 + Fix the longstanding issue of F-Spot changing photo timestamps
   (Paul Wellner Bou) (Closes: #445511) (LP: #175191)
 + Tons of translation updates (seriously)
* debian/control, debian/rules: Drop gnome-screensaver build-dep and set
  variables at configure time. Should reduce the BD chain significantly. 
* debian/control: Increase minimum version on libgphoto2-dev BD in line with
  configure requirements.
* debian/control: Add build-dependency on libunique-dev to build new
  unique-sharp bindings which f-spot now uses to handle activation.
* debian/patches/debian_link-system-mono-addins.patch: Drop, now upstream 
* debian/patches/*: Refresh to apply to new upstream version 
* debian/rules: Pass include directories to autoreconf to have the correct
  macros in scope for the new build system 
* debian/patches/ubuntu*: Steal patches from Ubuntu package to improve
  --view mode and add an undo/redo stack. Rebase on new upstream version.
  Thanks to Chris Halse Rogers.
* debian/patches/ubuntu_fname_quote_percent.patch: Drop, now upstream.
* debian/patches/git_transition_duration.patch: Cherrypick patch from
  upstream to reduce the transition duration when entering fullscreen to
  600ms. 
* debian/rules: Incorporate Ubuntu specific changes, and guard by a call to
  dpkg-vendor.
* debian/rules: Don't try to install the gconf schemas when building 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//
2
 
// AddinInstallDialog.cs
3
 
//
4
 
// Author:
5
 
//   Lluis Sanchez Gual
6
 
//
7
 
// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
8
 
//
9
 
// Permission is hereby granted, free of charge, to any person obtaining
10
 
// a copy of this software and associated documentation files (the
11
 
// "Software"), to deal in the Software without restriction, including
12
 
// without limitation the rights to use, copy, modify, merge, publish,
13
 
// distribute, sublicense, and/or sell copies of the Software, and to
14
 
// permit persons to whom the Software is furnished to do so, subject to
15
 
// the following conditions:
16
 
// 
17
 
// The above copyright notice and this permission notice shall be
18
 
// included in all copies or substantial portions of the Software.
19
 
// 
20
 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
 
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22
 
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23
 
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24
 
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25
 
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26
 
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
 
//
28
 
 
29
 
 
30
 
using System;
31
 
using System.Text;
32
 
using System.Threading;
33
 
using System.Collections;
34
 
using System.Collections.Specialized;
35
 
using System.Diagnostics;
36
 
using Mono.Unix;
37
 
 
38
 
using Gtk;
39
 
 
40
 
using Mono.Addins.Setup;
41
 
using Mono.Addins.Description;
42
 
 
43
 
namespace Mono.Addins.Gui
44
 
{
45
 
        partial class AddinInstallDialog : Dialog
46
 
        {
47
 
                ListStore repoStore;
48
 
                AddinTreeWidget tree;
49
 
                bool installing;
50
 
                
51
 
                PackageCollection packagesToInstall;
52
 
                string uninstallId;
53
 
                
54
 
                InstallMonitor installMonitor;
55
 
                SetupService service;
56
 
                
57
 
                
58
 
                public AddinInstallDialog (SetupService service)
59
 
                {
60
 
                        Build ();
61
 
                        this.service = service;
62
 
                        wizardNotebook.ShowTabs = false;
63
 
                        ActionArea.Hide ();
64
 
                        
65
 
                        tree = new InstallAddinTreeWidget (addinTree);
66
 
                        tree.AllowSelection = true;
67
 
                        tree.SelectionChanged += new EventHandler (OnAddinSelectionChanged);
68
 
                        
69
 
                        repoStore = new ListStore (typeof(string), typeof(string));
70
 
                        repoCombo.Model = repoStore;
71
 
                        CellRendererText crt = new CellRendererText ();
72
 
                        repoCombo.PackStart (crt, true);
73
 
                        repoCombo.AddAttribute (crt, "text", 0);
74
 
                        filterComboBox.Active = 1;
75
 
                        
76
 
                        imageInstall.Stock = "md-software-update";
77
 
                        imageInstall.IconSize = (int)IconSize.Dialog;
78
 
                        
79
 
                        FillRepos ();
80
 
                        repoCombo.Active = 0;
81
 
                        LoadAddins ();
82
 
                        FillAddinInfo ();
83
 
                        OnPageChanged ();
84
 
                }
85
 
                
86
 
                public override void Dispose ()
87
 
                {
88
 
                        base.Dispose ();
89
 
                        Destroy ();
90
 
                }
91
 
                
92
 
                void FillRepos ()
93
 
                {
94
 
                        int i = repoCombo.Active;
95
 
                        repoStore.Clear ();
96
 
                        
97
 
                        repoStore.AppendValues (Catalog.GetString ("All registered repositories"), "");
98
 
                        
99
 
                        foreach (AddinRepository rep in service.Repositories.GetRepositories ()) {
100
 
                                repoStore.AppendValues (rep.Title, rep.Url);
101
 
                        }
102
 
                        repoCombo.Active = i;
103
 
                }
104
 
                
105
 
                void LoadAddins ()
106
 
                {
107
 
                        object s = tree.SaveStatus ();
108
 
                        
109
 
                        tree.Clear ();
110
 
                        
111
 
                        Gtk.TreeIter iter;
112
 
                        if (!repoCombo.GetActiveIter (out iter))
113
 
                                return;
114
 
                                
115
 
                        bool showUpdates = filterComboBox.Active >= 1;
116
 
                        bool showNotInstalled = filterComboBox.Active <= 1;
117
 
                        
118
 
                        string rep = (string) repoStore.GetValue (iter, 1);
119
 
                        
120
 
                        AddinRepositoryEntry[] reps;
121
 
                        if (rep == "")
122
 
                                reps = service.Repositories.GetAvailableAddins ();
123
 
                        else
124
 
                                reps = service.Repositories.GetAvailableAddins (rep);
125
 
                        
126
 
                        foreach (AddinRepositoryEntry arep in reps)
127
 
                        {
128
 
                                if (!Services.InApplicationNamespace (service, arep.Addin.Id))
129
 
                                        continue;
130
 
                                
131
 
                                // Find whatever version is installed
132
 
                                Addin sinfo = AddinManager.Registry.GetAddin (Addin.GetIdName (arep.Addin.Id));
133
 
                                
134
 
                                if (sinfo == null) {
135
 
                                        if (showNotInstalled)
136
 
                                                tree.AddAddin (arep.Addin, arep, true);
137
 
                                        continue;
138
 
                                }
139
 
                                
140
 
                                if (showUpdates && Addin.CompareVersions (sinfo.Version, arep.Addin.Version) <= 0)
141
 
                                        continue;
142
 
                                
143
 
                                tree.AddAddin (arep.Addin, arep, true);
144
 
                        }
145
 
                        FillAddinInfo ();
146
 
                        
147
 
                        // Only show the select all button when "Show updates only" is selected
148
 
                        btnSelectAll.Visible = filterComboBox.Active == 2;
149
 
                        btnUnselectAll.Visible = filterComboBox.Active == 2;
150
 
                        
151
 
                        tree.RestoreStatus (s);
152
 
                }
153
 
                
154
 
                void OnAddinSelectionChanged (object o, EventArgs e)
155
 
                {
156
 
                        UpdateAddinSelection ();
157
 
                }
158
 
                        
159
 
                void UpdateAddinSelection ()
160
 
                {
161
 
                        btnNext.Sensitive = (tree.GetSelectedAddins().Length != 0);
162
 
                }
163
 
                
164
 
                protected void OnActiveAddinChanged (object o, EventArgs e)
165
 
                {
166
 
                        FillAddinInfo ();
167
 
                }
168
 
                
169
 
                protected void OnNextPage (object sender, EventArgs e)
170
 
                {
171
 
                        wizardNotebook.NextPage ();
172
 
                        OnPageChanged ();
173
 
                }
174
 
                
175
 
                protected void OnPrevPage (object sender, EventArgs e)
176
 
                {
177
 
                        wizardNotebook.PrevPage ();
178
 
                        OnPageChanged ();
179
 
                }
180
 
                
181
 
                protected void OnCancel (object sender, EventArgs e)
182
 
                {
183
 
                        if (installing) {
184
 
                                if (Services.AskQuestion (Catalog.GetString ("Are you sure you want to cancel the installation?")))
185
 
                                        installMonitor.Cancel ();
186
 
                        } else
187
 
                                Respond (ResponseType.Cancel);
188
 
                }
189
 
                
190
 
                protected void OnOk (object sender, EventArgs e)
191
 
                {
192
 
                        Respond (ResponseType.Ok);
193
 
                }
194
 
                
195
 
                protected void OnManageSites (object sender, EventArgs e)
196
 
                {
197
 
                        ManageSitesDialog dlg = new ManageSitesDialog (service);
198
 
                        dlg.TransientFor = this;
199
 
                        try {
200
 
                                dlg.Run ();
201
 
                                FillRepos ();
202
 
                        } finally {
203
 
                                dlg.Destroy ();
204
 
                        }
205
 
                }
206
 
 
207
 
 
208
 
                bool updateDone;
209
 
                
210
 
                protected void OnUpdateRepo (object sender, EventArgs e)
211
 
                {
212
 
                        Thread t = new Thread (new ThreadStart (RunUpdate));
213
 
                        t.Start ();
214
 
                        updateDone = false;
215
 
                        while (!updateDone) {
216
 
                                while (Gtk.Application.EventsPending ())
217
 
                                        Gtk.Application.RunIteration ();
218
 
                                Thread.Sleep (50);
219
 
                        }
220
 
                        LoadAddins ();
221
 
                }
222
 
                
223
 
                void RunUpdate ()
224
 
                {
225
 
                        try {
226
 
                                service.Repositories.UpdateAllRepositories (null);
227
 
                        } finally {
228
 
                                updateDone = true;
229
 
                        }
230
 
                }
231
 
                
232
 
                protected void OnRepoChanged (object sender, EventArgs e)
233
 
                {
234
 
                        LoadAddins ();
235
 
                }
236
 
                
237
 
                public void OnPageChanged ()
238
 
                {
239
 
                        switch (wizardNotebook.CurrentPage) {
240
 
                        case 0:
241
 
                                btnPrev.Sensitive = false;
242
 
                                btnNext.Sensitive = (tree.GetSelectedAddins().Length != 0);
243
 
                                break;
244
 
                        case 1:
245
 
                                FillSummaryPage ();
246
 
                                break;
247
 
                        case 2:
248
 
                                Install ();
249
 
                                break;
250
 
                        case 3:
251
 
                                btnPrev.Hide ();
252
 
                                btnNext.Hide ();
253
 
                                btnCancel.Hide ();
254
 
                                btnOk.Show ();
255
 
                                break;
256
 
                        }
257
 
                }
258
 
                
259
 
                protected void OnGotoWeb (object sender, EventArgs e)
260
 
                {
261
 
                        AddinHeader info = tree.ActiveAddin;
262
 
                        if (info == null)
263
 
                                return;
264
 
                                
265
 
                        if (info.Url != "")
266
 
                                Process.Start (info.Url);
267
 
                }
268
 
                
269
 
                protected void OnShowInfo (object sender, EventArgs e)
270
 
                {
271
 
                        AddinHeader info = tree.ActiveAddin;
272
 
                        if (info == null)
273
 
                                return;
274
 
 
275
 
                        AddinInfoDialog dlg = new AddinInfoDialog (info);
276
 
                        try {
277
 
                                dlg.Run ();
278
 
                        } finally {
279
 
                                dlg.Destroy ();
280
 
                        }
281
 
                }
282
 
 
283
 
                protected void OnFilterChanged (object sender, EventArgs e)
284
 
                {
285
 
                        LoadAddins ();
286
 
                        UpdateAddinSelection ();
287
 
                }
288
 
                
289
 
                protected void OnSelectAll (object sender, EventArgs e)
290
 
                {
291
 
                        tree.SelectAll ();
292
 
                }
293
 
                
294
 
                protected void OnUnselectAll (object sender, EventArgs e)
295
 
                {
296
 
                        tree.UnselectAll ();
297
 
                }
298
 
                
299
 
                public void SetUninstallMode (AddinHeader info)
300
 
                {
301
 
                        btnPrev.Hide ();
302
 
                        btnNext.Sensitive = true;
303
 
                        
304
 
                        uninstallId = info.Id;
305
 
                        wizardNotebook.CurrentPage = 1;
306
 
                        
307
 
                        StringBuilder sb = new StringBuilder ();
308
 
                        sb.Append ("<b>").Append (Catalog.GetString ("The following packages will be uninstalled:")).Append ("</b>\n\n");
309
 
                        sb.Append (info.Name + "\n\n");
310
 
                        
311
 
                        Addin[] sinfos = service.GetDependentAddins (info.Id, true);
312
 
                        if (sinfos.Length > 0) {
313
 
                                sb.Append ("<b>").Append (Catalog.GetString ("There are other extensions that depend on the previous ones which will also be uninstalled:")).Append ("</b>\n\n");
314
 
                                foreach (Addin si in sinfos)
315
 
                                        sb.Append (si.Description.Name + "\n");
316
 
                        }
317
 
                        
318
 
                        labelSummary.Markup = sb.ToString ();
319
 
                }
320
 
                
321
 
                void FillAddinInfo ()
322
 
                {
323
 
                        AddinHeader info = tree.ActiveAddin;
324
 
                        btnInfo.Sensitive = info != null;
325
 
                        
326
 
/*                      if (info == null) {
327
 
                                infoLabel.Markup = "";
328
 
                                linkLabel.Visible = false;
329
 
                                return;
330
 
                        }
331
 
                                
332
 
                        StringBuilder sb = new StringBuilder ();
333
 
                        sb.Append ("<b><big>" + info.Name + "</big></b>\n\n");
334
 
                        
335
 
                        if (info.Description != "")
336
 
                                sb.Append (info.Description + "\n\n");
337
 
                        
338
 
                        sb.Append ("<small>");
339
 
                        
340
 
                        sb.Append ("<b>").Append (Catalog.GetString ("Version:")).Append ("</b>\n").Append (info.Version).Append ("\n\n");
341
 
                        
342
 
                        if (info.Author != "")
343
 
                                sb.Append ("<b>").Append (Catalog.GetString ("Author:")).Append ("</b>\n").Append (info.Author).Append ("\n\n");
344
 
                        
345
 
                        if (info.Copyright != "")
346
 
                                sb.Append ("<b>").Append (Catalog.GetString ("Copyright:")).Append ("</b>\n").Append (info.Copyright).Append ("\n\n");
347
 
                        
348
 
                        if (info.Dependencies.Count > 0) {
349
 
                                sb.Append ("<b>").Append (Catalog.GetString ("Extension Dependencies:")).Append ("</b>\n");
350
 
                                foreach (PackageDependency dep in info.Dependencies)
351
 
                                        sb.Append (dep.Name + "\n");
352
 
                        }
353
 
                        
354
 
                        sb.Append ("</small>");
355
 
                        
356
 
                        linkLabel.Visible = info.Url != "";
357
 
                                
358
 
                        infoLabel.Markup = sb.ToString ();*/
359
 
                }
360
 
 
361
 
                
362
 
                void FillSummaryPage ()
363
 
                {
364
 
                        btnPrev.Sensitive = true;
365
 
                        
366
 
                        AddinHeader[] infos = tree.GetSelectedAddins ();
367
 
                        PackageCollection packs = new PackageCollection ();
368
 
                        foreach (AddinHeader info in infos) {
369
 
                                AddinRepositoryEntry arep = (AddinRepositoryEntry) tree.GetAddinData (info);
370
 
                                packs.Add (Package.FromRepository (arep));
371
 
                        }
372
 
                        
373
 
                        packagesToInstall = new PackageCollection (packs);
374
 
                        
375
 
                        PackageCollection toUninstall;
376
 
                        DependencyCollection unresolved;
377
 
                        bool res;
378
 
                        
379
 
                        InstallMonitor m = new InstallMonitor ();
380
 
                        res = service.ResolveDependencies (m, packs, out toUninstall, out unresolved);
381
 
                        
382
 
                        StringBuilder sb = new StringBuilder ();
383
 
                        if (!res) {
384
 
                                sb.Append ("<b><span foreground=\"red\">").Append (Catalog.GetString ("The selected extensions can't be installed because there are dependency conflicts.")).Append ("</span></b>\n");
385
 
                                foreach (string s in m.Errors) {
386
 
                                        sb.Append ("<b><span foreground=\"red\">" + s + "</span></b>\n");
387
 
                                }
388
 
                                sb.Append ("\n");
389
 
                        }
390
 
                        
391
 
                        if (m.Warnings.Count != 0) {
392
 
                                foreach (string w in m.Warnings) {
393
 
                                        sb.Append ("<b><span foreground=\"red\">" + w + "</span></b>\n");
394
 
                                }
395
 
                                sb.Append ("\n");
396
 
                        }
397
 
                        
398
 
                        sb.Append ("<b>").Append (Catalog.GetString ("The following packages will be installed:")).Append ("</b>\n\n");
399
 
                        foreach (Package p in packs) {
400
 
                                sb.Append (p.Name);
401
 
                                if (!p.SharedInstall)
402
 
                                        sb.Append (Catalog.GetString (" (in user directory)"));
403
 
                                sb.Append ("\n");
404
 
                        }
405
 
                        sb.Append ("\n");
406
 
                        
407
 
                        if (toUninstall.Count > 0) {
408
 
                                sb.Append ("<b>").Append (Catalog.GetString ("The following packages need to be uninstalled:")).Append ("</b>\n\n");
409
 
                                foreach (Package p in toUninstall) {
410
 
                                        sb.Append (p.Name + "\n");
411
 
                                }
412
 
                                sb.Append ("\n");
413
 
                        }
414
 
                        
415
 
                        if (unresolved.Count > 0) {
416
 
                                sb.Append ("<b>").Append (Catalog.GetString ("The following dependencies could not be resolved:")).Append ("</b>\n\n");
417
 
                                foreach (Dependency p in unresolved) {
418
 
                                        sb.Append (p.Name + "\n");
419
 
                                }
420
 
                                sb.Append ("\n");
421
 
                        }
422
 
                        btnNext.Sensitive = res;
423
 
                        labelSummary.Markup = sb.ToString ();
424
 
                }
425
 
                
426
 
                void Install ()
427
 
                {
428
 
                        btnPrev.Sensitive = false;
429
 
                        btnNext.Sensitive = false;
430
 
                        
431
 
                        string txt;
432
 
                        string okmessage;
433
 
                        string errmessage;
434
 
                        string warnmessage;
435
 
                        
436
 
                        installMonitor = new InstallMonitor (progressLabel, progressBar, mainProgressBar);
437
 
                        ThreadStart oper;
438
 
                                
439
 
                        if (uninstallId == null) {
440
 
                                oper = new ThreadStart (RunInstall);
441
 
                                okmessage = Catalog.GetString ("The installation has been successfully completed.");
442
 
                                errmessage = Catalog.GetString ("The installation failed!");
443
 
                                warnmessage = Catalog.GetString ("The installation has completed with warnings.");
444
 
                        } else {
445
 
                                oper = new ThreadStart (RunUninstall);
446
 
                                okmessage = Catalog.GetString ("The uninstallation has been successfully completed.");
447
 
                                errmessage = Catalog.GetString ("The uninstallation failed!");
448
 
                                warnmessage = Catalog.GetString ("The uninstallation has completed with warnings.");
449
 
                        }
450
 
                        
451
 
                        Thread t = new Thread (oper);
452
 
                        t.Start ();
453
 
                        
454
 
                        installing = true;
455
 
                        installMonitor.WaitForCompleted ();
456
 
                        installing = false;
457
 
                        
458
 
                        wizardNotebook.NextPage ();
459
 
 
460
 
                        if (installMonitor.Success && installMonitor.Warnings.Count == 0) {
461
 
                                imageWarn.Visible = false;
462
 
                                imageError.Visible = false;
463
 
                                imageInfo.Visible = true;
464
 
                                txt = "<b>" + okmessage + "</b>\n\n";
465
 
                        } else if (installMonitor.Success) {
466
 
                                imageWarn.Visible = true;
467
 
                                imageInfo.Visible = false;
468
 
                                imageError.Visible = false;
469
 
                                txt = "<b>" + warnmessage + "</b>\n\n";
470
 
                                foreach (string s in installMonitor.Warnings)
471
 
                                        txt += GLib.Markup.EscapeText (s) + "\n";
472
 
                        } else {
473
 
                                imageWarn.Visible = false;
474
 
                                imageInfo.Visible = false;
475
 
                                imageError.Visible = true;
476
 
                                txt = "<span foreground=\"red\"><b>" + errmessage + "</b></span>\n\n";
477
 
                                foreach (string s in installMonitor.Errors)
478
 
                                        txt += GLib.Markup.EscapeText (s) + "\n";
479
 
                        }
480
 
                        
481
 
                        labelResult.Markup = txt;
482
 
                        OnPageChanged ();
483
 
                }
484
 
                
485
 
                void RunInstall ()
486
 
                {
487
 
                        try {
488
 
                                service.Install (installMonitor, packagesToInstall);
489
 
                        } catch {
490
 
                                // Nothing
491
 
                        } finally {
492
 
                                installMonitor.Dispose ();
493
 
                        }
494
 
                }
495
 
                
496
 
                void RunUninstall ()
497
 
                {
498
 
                        try {
499
 
                                service.Uninstall (installMonitor, uninstallId);
500
 
                        } catch {
501
 
                                // Nothing
502
 
                        } finally {
503
 
                                installMonitor.Dispose ();
504
 
                        }
505
 
                }
506
 
        }
507
 
        
508
 
        class InstallMonitor: IProgressStatus, IDisposable
509
 
        {
510
 
                Label progressLabel;
511
 
                ProgressBar progressBar;
512
 
                ProgressBar mainProgressBar;
513
 
                StringCollection errors = new StringCollection ();
514
 
                StringCollection warnings = new StringCollection ();
515
 
                bool canceled;
516
 
                bool done;
517
 
                
518
 
                public InstallMonitor (Label progressLabel, ProgressBar progressBar, ProgressBar mainProgressBar)
519
 
                {
520
 
                        this.progressLabel = progressLabel;
521
 
                        this.progressBar = progressBar;
522
 
                        this.mainProgressBar = mainProgressBar;
523
 
                }
524
 
                
525
 
                public InstallMonitor ()
526
 
                {
527
 
                }
528
 
                
529
 
                public void SetMessage (string msg)
530
 
                {
531
 
                        if (progressLabel != null)
532
 
                                progressLabel.Text = msg;
533
 
                }
534
 
                
535
 
                public void SetProgress (double progress)
536
 
                {
537
 
                        if (mainProgressBar != null)
538
 
                                mainProgressBar.Fraction = progress;
539
 
                        if (progressBar != null)
540
 
                                progressBar.Fraction = progress;
541
 
                }
542
 
                
543
 
                public void Log (string msg)
544
 
                {
545
 
                        Console.WriteLine (msg);
546
 
                }
547
 
                
548
 
                public void ReportWarning (string message)
549
 
                {
550
 
                        warnings.Add (message);
551
 
                }
552
 
                
553
 
                public void ReportError (string message, Exception exception)
554
 
                {
555
 
                        errors.Add (message);
556
 
                }
557
 
                
558
 
                public bool IsCanceled {
559
 
                        get { return canceled; }
560
 
                }
561
 
                
562
 
                public StringCollection Errors {
563
 
                        get { return errors; }
564
 
                }
565
 
                
566
 
                public StringCollection Warnings {
567
 
                        get { return warnings; }
568
 
                }
569
 
                
570
 
                public void Cancel ()
571
 
                {
572
 
                        canceled = true;
573
 
                }
574
 
                
575
 
                public int LogLevel {
576
 
                        get { return 1; }
577
 
                }
578
 
                
579
 
                public void Dispose ()
580
 
                {
581
 
                        done = true;
582
 
                }
583
 
                
584
 
                public void WaitForCompleted ()
585
 
                {
586
 
                        while (!done) {
587
 
                                while (Gtk.Application.EventsPending ())
588
 
                                        Gtk.Application.RunIteration ();
589
 
                                Thread.Sleep (50);
590
 
                        }
591
 
                }
592
 
                
593
 
                public bool Success {
594
 
                        get { return errors.Count == 0; }
595
 
                }
596
 
        }
597
 
        
598
 
        class InstallAddinTreeWidget: AddinTreeWidget
599
 
        {
600
 
                int ncol;
601
 
                public InstallAddinTreeWidget (Gtk.TreeView treeView): base (treeView)
602
 
                {
603
 
                }
604
 
                
605
 
                protected override void AddStoreTypes (ArrayList list)
606
 
                {
607
 
                        base.AddStoreTypes (list);
608
 
                        ncol = list.Count;
609
 
                        list.Add (typeof(string));
610
 
                }
611
 
                
612
 
                protected override void CreateColumns ()
613
 
                {
614
 
                        base.CreateColumns ();
615
 
                        TreeViewColumn col = new TreeViewColumn ();
616
 
                        col.Title = Catalog.GetString ("Repository");
617
 
                        CellRendererText crt = new CellRendererText ();
618
 
                        col.PackStart (crt, true);
619
 
                        col.AddAttribute (crt, "text", ncol);
620
 
                        treeView.AppendColumn (col);
621
 
                }
622
 
                
623
 
                protected override void UpdateRow (TreeIter iter, AddinHeader info, object dataItem, bool enabled, Gdk.Pixbuf icon)
624
 
                {
625
 
                        base.UpdateRow (iter, info, dataItem, enabled, icon);
626
 
                        AddinRepositoryEntry arep = (AddinRepositoryEntry) dataItem;
627
 
                        treeStore.SetValue (iter, ncol, arep.RepositoryName);
628
 
                }
629
 
        }
630
 
}
631