forked from hbons/SparkleShare
/
SparkleAbout.cs
155 lines (120 loc) · 5.32 KB
/
SparkleAbout.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
// SparkleShare, an instant update workflow to Git.
// Copyright (C) 2010 Hylke Bons (hylkebons@gmail.com)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see (http://www.gnu.org/licenses/).
using System;
using System.Diagnostics;
using System.IO;
using System.Net;
using Gtk;
using SparkleLib;
using Mono.Unix;
namespace SparkleShare {
public class SparkleAbout : Window {
private Label version;
// Short alias for the translations
public static string _(string s)
{
return Catalog.GetString (s);
}
public SparkleAbout () : base ("")
{
DefaultSize = new Gdk.Size (360, 260);
BorderWidth = 0;
IconName = "folder-sparkleshare";
WindowPosition = WindowPosition.Center;
Title = "About SparkleShare";
Resizable = false;
CreateAbout ();
SparkleShare.Controller.NewVersionAvailable += delegate (string new_version) {
Application.Invoke (delegate {
this.version.Markup = "<small><span fgcolor='#f57900'>A newer version (" + new_version + ") is available!</span></small>";
this.version.ShowAll ();
});
};
SparkleShare.Controller.VersionUpToDate += delegate {
Application.Invoke (delegate {
this.version.Markup = "<small><span fgcolor='#4e9a06'>You are running the latest version.</span></small>";
this.version.ShowAll ();
});
};
SparkleShare.Controller.CheckForNewVersion ();
}
private void CreateAbout ()
{
Gdk.Color color = Style.Foreground (StateType.Insensitive);
string secondary_text_color = SparkleUIHelpers.GdkColorToHex (color);
EventBox box = new EventBox ();
box.ModifyBg (StateType.Normal, new TreeView ().Style.Base (StateType.Normal));
Label header = new Label () {
Markup = "<span font_size='xx-large'>SparkleShare</span>\n<span fgcolor='" + secondary_text_color + "'><small>" + Defines.VERSION + "</small></span>",
Xalign = 0,
Xpad = 18,
Ypad = 18
};
box.Add (header);
this.version = new Label () {
Markup = "<small>Checking for updates...</small>",
Xalign = 0,
Xpad = 18,
Ypad = 22,
};
Label license = new Label () {
Xalign = 0,
Xpad = 18,
Ypad = 0,
LineWrap = true,
Wrap = true,
LineWrapMode = Pango.WrapMode.Word,
Markup = "<small>Copyright © 2010–" + DateTime.Now.Year + " Hylke Bons and others\n" +
"\n" +
"SparkleShare is Free and Open Source Software. " +
"You are free to use, modify, and redistribute it " +
"under the terms of the GNU General Public License version 3 or later.</small>"
};
VBox vbox = new VBox (false, 0) {
BorderWidth = 0
};
HButtonBox button_bar = new HButtonBox () {
BorderWidth = 12
};
Button credits_button = new Button (_("_Show Credits")) {
UseUnderline = true
};
credits_button.Clicked += delegate {
Process process = new Process ();
process.StartInfo.FileName = "xdg-open";
process.StartInfo.Arguments = "http://www.sparkleshare.org/credits";
process.Start ();
};
Button website_button = new Button (_("_Visit Website")) {
UseUnderline = true
};
website_button.Clicked += delegate {
Process process = new Process ();
process.StartInfo.FileName = "xdg-open";
process.StartInfo.Arguments = "http://www.sparkleshare.org/";
process.Start ();
};
button_bar.Add (website_button);
button_bar.Add (credits_button);
vbox.PackStart (box, true, true, 0);
vbox.PackStart (this.version, false, false, 0);
vbox.PackStart (license, true, true, 0);
vbox.PackStart (new Label (""), true, true, 0);
vbox.PackStart (button_bar, false, false, 0);
Add (vbox);
}
}
}