5
// Michael Hutchinson <mhutchinson@novell.com>
7
// Copyright (c) 2009 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
28
using System.Collections.Generic;
32
using MonoDevelop.Core;
34
namespace MonoDevelop.Platform
38
partial class UpdateDialog : Gtk.Dialog
41
public UpdateDialog (List<AppUpdater.Update> updates)
44
checkAutomaticallyCheck.Active = AppUpdater.CheckAutomatically;
45
checkAutomaticallyCheck.Toggled += delegate {
46
AppUpdater.CheckAutomatically = checkAutomaticallyCheck.Active;
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"))
54
productBox.ShowAll ();
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);
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),
67
labelBox.PackStart (updateExpander, true, true, 0);
69
var downloadButton = new Button () {
70
Label = GettextCatalog.GetString ("Download")
73
//NOTE: grab the variable from the loop var so the closure captures it
75
downloadButton.Clicked += delegate {
76
MonoDevelop.Core.Gui.DesktopService.ShowUrl (url);
78
labelBox.PackStart (downloadButton, false, false, 0);
80
var sb = new StringBuilder ();
81
for (int i = 0; i < update.Releases.Count; i++) {
82
var release = update.Releases[i];
86
sb.AppendLine ("This release also includes previous updates:");
89
sb.AppendFormat ("{0} ({1:yyyy-MM-dd})\n", release.Version, release.Date);
92
sb.Append (release.Notes.Trim ('\t', ' ', '\n', '\r'));
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);
103
updateExpander.Activated += delegate {
104
textView.Visible = updateExpander.Expanded;
107
var f = new Frame () {
110
ShadowType = ShadowType.In
112
updateBox.BorderWidth = 6;
113
productBox.Spacing = 2;
114
productBox.PackStart (f, false, false, 0);
117
textView.Visible = false;