~ubuntu-branches/ubuntu/lucid/monodevelop/lucid

« back to all changes in this revision

Viewing changes to src/addins/MacPlatform/UpdateDialog.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2010-02-02 11:39:59 UTC
  • mfrom: (1.2.6 upstream) (1.3.7 sid)
  • Revision ID: james.westby@ubuntu.com-20100202113959-s4exdz7er7igylz2
Tags: 2.2.1+dfsg-1
* New upstream release
* debian/control:
  + Standards version 3.8.4 (no changes needed)
* debian/patches/remove_support_for_non_debian_functionality.patch,
  debian/patches/remove_support_for_soft_debugger.patch,
  debian/patches/remove_support_for_moonlight.patch,
  debian/rules:
  + Split patch into two pieces, to make it easier to enable either
    SDB or Moonlight support with a rebuild
* debian/monodevelop-moonlight.install,
  debian/monodevelop-debugger-sdb.install,
  debian/control:
  + Create packaging data for the Soft Debugger addin and Moonlight addin -
    and comment them out of debian/control as we can't provide them on
    Debian for now

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// 
2
 
// UpdateDialog.cs
3
 
//  
4
 
// Author:
5
 
//       Michael Hutchinson <mhutchinson@novell.com>
6
 
// 
7
 
// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
8
 
// 
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:
15
 
// 
16
 
// The above copyright notice and this permission notice shall be included in
17
 
// all copies or substantial portions of the Software.
18
 
// 
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
25
 
// THE SOFTWARE.
26
 
 
27
 
using System;
28
 
using System.Collections.Generic;
29
 
using System.Text;
30
 
 
31
 
using Gtk;
32
 
using MonoDevelop.Core;
33
 
 
34
 
namespace MonoDevelop.Platform
35
 
{
36
 
 
37
 
 
38
 
        partial class UpdateDialog : Gtk.Dialog
39
 
        {
40
 
 
41
 
                public UpdateDialog (List<AppUpdater.Update> updates)
42
 
                {
43
 
                        this.Build ();
44
 
                        checkAutomaticallyCheck.Active = AppUpdater.CheckAutomatically;
45
 
                        checkAutomaticallyCheck.Toggled += delegate {
46
 
                                AppUpdater.CheckAutomatically = checkAutomaticallyCheck.Active;
47
 
                        };
48
 
                        
49
 
                        if (updates == null || updates.Count == 0) {
50
 
                                ((VBox)infoLabel.Parent).Remove (infoLabel);
51
 
                                productBox.PackStart (new Alignment (0.5f, 0.5f, 0f, 0f) {
52
 
                                        Child = new Label (GettextCatalog.GetString ("No updates available"))
53
 
                                }, true, true, 0);
54
 
                                productBox.ShowAll ();
55
 
                                return;
56
 
                        }
57
 
                        
58
 
                        foreach (var update in updates) {
59
 
                                var updateBox = new VBox () { Spacing = 2 };
60
 
                                var labelBox = new HBox ();
61
 
                                updateBox.PackStart (labelBox, false, false, 0);
62
 
                                
63
 
                                var updateExpander = new Expander ("");
64
 
                                updateExpander.LabelWidget = new Label () {
65
 
                                        Markup = string.Format ("<b>{0}</b> {1} ({2:yyyy-MM-dd})", update.Name, update.Version, update.Date),
66
 
                                };
67
 
                                labelBox.PackStart (updateExpander, true, true, 0);
68
 
                                
69
 
                                var downloadButton = new Button () {
70
 
                                        Label = GettextCatalog.GetString ("Download")
71
 
                                };
72
 
                                
73
 
                                //NOTE: grab the variable from the loop var so the closure captures it 
74
 
                                var url = update.Url;
75
 
                                downloadButton.Clicked += delegate {
76
 
                                        MonoDevelop.Core.Gui.DesktopService.ShowUrl (url);
77
 
                                };
78
 
                                labelBox.PackStart (downloadButton, false, false, 0);
79
 
                                
80
 
                                var sb = new StringBuilder ();
81
 
                                for (int i = 0; i < update.Releases.Count; i++) {
82
 
                                        var release = update.Releases[i];
83
 
                                        if (i > 0) {
84
 
                                                if (i == 1) {
85
 
                                                        sb.AppendLine ();
86
 
                                                        sb.AppendLine ("This release also includes previous updates:");
87
 
                                                }
88
 
                                                sb.AppendLine ();
89
 
                                                sb.AppendFormat ("{0} ({1:yyyy-MM-dd})\n", release.Version, release.Date);
90
 
                                                sb.AppendLine ();
91
 
                                        }
92
 
                                        sb.Append (release.Notes.Trim ('\t', ' ', '\n', '\r'));
93
 
                                        sb.AppendLine ();
94
 
                                }
95
 
                                var buffer = new TextBuffer (null);
96
 
                                buffer.Text = sb.ToString ();
97
 
                                var textView = new TextView (buffer);
98
 
                                textView.WrapMode = WrapMode.Word;
99
 
                                textView.Editable = false;
100
 
                                textView.LeftMargin = textView.RightMargin = 4;
101
 
                                updateBox.PackStart (textView, false, false, 0);
102
 
                                
103
 
                                updateExpander.Activated += delegate {
104
 
                                        textView.Visible = updateExpander.Expanded;
105
 
                                };
106
 
                                
107
 
                                var f = new Frame () {
108
 
                                        BorderWidth = 2,
109
 
                                        Child = updateBox,
110
 
                                        ShadowType = ShadowType.In
111
 
                                };
112
 
                                updateBox.BorderWidth = 6;
113
 
                                productBox.Spacing = 2;
114
 
                                productBox.PackStart (f, false, false, 0);
115
 
                                f.ShowAll ();
116
 
                                
117
 
                                textView.Visible = false;
118
 
                        }
119
 
                }
120
 
        }
121
 
}