2
// AddinInstallDialog.cs
5
// Lluis Sanchez Gual <lluis@novell.com>
7
// Copyright (c) 2011 Novell, Inc (http://www.novell.com)
9
// Permission is hereby granted, free of charge, to any person obtaining a copy
10
// of this software and associated documentation files (the "Software"), to deal
11
// in the Software without restriction, including without limitation the rights
12
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
// copies of the Software, and to permit persons to whom the Software is
14
// furnished to do so, subject to the following conditions:
16
// The above copyright notice and this permission notice shall be included in
17
// all copies or substantial portions of the Software.
19
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29
using System.Threading;
30
using System.Collections;
31
using System.Collections.Specialized;
32
using System.Diagnostics;
35
using Mono.Addins.Setup;
36
using Mono.Addins.Description;
37
namespace Mono.Addins.Gui
39
class InstallMonitor: IProgressStatus, IDisposable
42
ProgressBar progressBar;
43
StringCollection errors = new StringCollection ();
44
StringCollection warnings = new StringCollection ();
49
public InstallMonitor (Label progressLabel, ProgressBar progressBar, string mainOperation)
51
this.progressLabel = progressLabel;
52
this.progressBar = progressBar;
53
this.mainOperation = mainOperation;
56
public InstallMonitor ()
60
public void SetMessage (string msg)
62
if (progressLabel != null)
63
progressLabel.Markup = "<b>" + GLib.Markup.EscapeText (mainOperation) + "</b>\n" + GLib.Markup.EscapeText (msg);
67
public void SetProgress (double progress)
69
if (progressBar != null)
70
progressBar.Fraction = progress;
74
public void Log (string msg)
76
Console.WriteLine (msg);
79
public void ReportWarning (string message)
81
warnings.Add (message);
84
public void ReportError (string message, Exception exception)
89
public bool IsCanceled {
90
get { return canceled; }
93
public StringCollection Errors {
94
get { return errors; }
97
public StringCollection Warnings {
98
get { return warnings; }
101
public void Cancel ()
106
public int LogLevel {
110
public void Dispose ()
115
public void WaitForCompleted ()
123
public bool Success {
124
get { return errors.Count == 0; }
127
void RunPendingEvents ()
129
while (Gtk.Application.EventsPending ())
130
Gtk.Application.RunIteration ();