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

« back to all changes in this revision

Viewing changes to lib/mono-addins/Mono.Addins.Setup/Mono.Addins.Setup.ProgressMonitoring/ConsoleProgressMonitor.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
 
// ConsoleProgressMonitor.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
 
using System;
30
 
using System.IO;
31
 
 
32
 
namespace Mono.Addins.Setup.ProgressMonitoring
33
 
{
34
 
        internal class ConsoleProgressMonitor: NullProgressMonitor
35
 
        {
36
 
                int columns = 80;
37
 
                bool indent = true;
38
 
                bool wrap = true;
39
 
                int ilevel = 0;
40
 
                int isize = 3;
41
 
                int col = -1;
42
 
                int logLevel;
43
 
                LogTextWriter logger;
44
 
                
45
 
                public ConsoleProgressMonitor (): this (1)
46
 
                {
47
 
                }
48
 
                
49
 
                public ConsoleProgressMonitor (int logLevel)
50
 
                {
51
 
                        this.logLevel = logLevel;
52
 
                        logger = new LogTextWriter ();
53
 
                        logger.TextWritten += new LogTextEventHandler (WriteLog);
54
 
                }
55
 
                
56
 
                public bool WrapText {
57
 
                        get { return wrap; }
58
 
                        set { wrap = value; }
59
 
                }
60
 
                
61
 
                public int WrapColumns {
62
 
                        get { return columns; }
63
 
                        set { columns = value; }
64
 
                }
65
 
                
66
 
                public bool IndentTasks {
67
 
                        get { return indent; }
68
 
                        set { indent = value; }
69
 
                }
70
 
                
71
 
                public override int LogLevel {
72
 
                        get { return logLevel; }
73
 
                }
74
 
                
75
 
                public override void BeginTask (string name, int totalWork)
76
 
                {
77
 
                        WriteText (name);
78
 
                        Indent ();
79
 
                }
80
 
                
81
 
                public override void BeginStepTask (string name, int totalWork, int stepSize)
82
 
                {
83
 
                        BeginTask (name, totalWork);
84
 
                }
85
 
                
86
 
                public override void EndTask ()
87
 
                {
88
 
                        Unindent ();
89
 
                }
90
 
                
91
 
                void WriteLog (string text)
92
 
                {
93
 
                        WriteText (text);
94
 
                }
95
 
                
96
 
                public override TextWriter Log {
97
 
                        get { return logger; }
98
 
                }
99
 
                
100
 
                public override void ReportSuccess (string message)
101
 
                {
102
 
                        WriteText (message);
103
 
                }
104
 
                
105
 
                public override void ReportWarning (string message)
106
 
                {
107
 
                        if (logLevel != 0)
108
 
                                WriteText ("WARNING: " + message + "\n");
109
 
                }
110
 
                
111
 
                public override void ReportError (string message, Exception ex)
112
 
                {
113
 
                        if (logLevel == 0)
114
 
                                return;
115
 
                        
116
 
                        if (message != null && ex != null) {
117
 
                                WriteText ("ERROR: " + message + "\n");
118
 
                                if (logLevel > 1)
119
 
                                        WriteText (ex + "\n");
120
 
                        }
121
 
                        if (message != null)
122
 
                                WriteText ("ERROR: " + message + "\n");
123
 
                        else if (ex != null) {
124
 
                                if (logLevel > 1)
125
 
                                        WriteText ("ERROR: " + ex + "\n");
126
 
                                else
127
 
                                        WriteText ("ERROR: " + ex.Message + "\n");
128
 
                        }
129
 
                }
130
 
                
131
 
                void WriteText (string text)
132
 
                {
133
 
                        if (indent)
134
 
                                WriteText (text, ilevel);
135
 
                        else
136
 
                                WriteText (text, 0);
137
 
                }
138
 
                
139
 
                void WriteText (string text, int leftMargin)
140
 
                {
141
 
                        if (text == null || text.Length == 0)
142
 
                                return;
143
 
 
144
 
                        int n = 0;
145
 
                        int maxCols = wrap ? columns : int.MaxValue;
146
 
 
147
 
                        while (n < text.Length)
148
 
                        {
149
 
                                if (col == -1) {
150
 
                                        Console.Write (new String (' ', leftMargin));
151
 
                                        col = leftMargin;
152
 
                                }
153
 
                                
154
 
                                int lastWhite = -1;
155
 
                                int sn = n;
156
 
                                bool eol = false;
157
 
                                
158
 
                                while (col < maxCols && n < text.Length) {
159
 
                                        char c = text [n];
160
 
                                        if (c == '\r') {
161
 
                                                n++;
162
 
                                                continue;
163
 
                                        }
164
 
                                        if (c == '\n') {
165
 
                                                eol = true;
166
 
                                                break;
167
 
                                        }
168
 
                                        if (char.IsWhiteSpace (c))
169
 
                                                lastWhite = n;
170
 
                                        col++;
171
 
                                        n++;
172
 
                                }
173
 
                                
174
 
                                if (lastWhite == -1 || col < maxCols)
175
 
                                        lastWhite = n;
176
 
                                else if (col >= maxCols)
177
 
                                        n = lastWhite + 1;
178
 
                                
179
 
                                Console.Write (text.Substring (sn, lastWhite - sn));
180
 
                                
181
 
                                if (eol || col >= maxCols) {
182
 
                                        col = -1;
183
 
                                        Console.WriteLine ();
184
 
                                        if (eol) n++;
185
 
                                }
186
 
                        }
187
 
                }
188
 
                
189
 
                void Indent ()
190
 
                {
191
 
                        ilevel += isize;
192
 
                        if (col != -1) {
193
 
                                Console.WriteLine ();
194
 
                                col = -1;
195
 
                        }
196
 
                }
197
 
                
198
 
                void Unindent ()
199
 
                {
200
 
                        ilevel -= isize;
201
 
                        if (ilevel < 0) ilevel = 0;
202
 
                        if (col != -1) {
203
 
                                Console.WriteLine ();
204
 
                                col = -1;
205
 
                        }
206
 
                }
207
 
        }
208
 
}