4
* Copyright 2016 Tony George <teejeetech@gmail.com>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
27
using TeeJee.FileSystem;
28
using TeeJee.JsonHelper;
29
using TeeJee.ProcessHelper;
30
using TeeJee.GtkHelper;
34
public class AboutWindow : Dialog {
35
private Box vbox_main;
36
private Box vbox_logo;
37
private Box vbox_credits;
38
private Box vbox_lines;
39
private Box hbox_action;
40
private Button btn_credits;
41
private Button btn_close;
43
private Gtk.Image img_logo;
44
private Label lbl_program_name;
45
private Label lbl_version;
46
private Label lbl_comments;
47
private LinkButton lbtn_website;
48
private Label lbl_copyright;
50
private string[] _artists;
51
public string[] artists{
60
private string[] _authors;
61
public string[] authors{
70
private string[] _contributors;
71
public string[] contributors{
76
_contributors = value;
80
private string _comments = "";
81
public string comments{
90
private string _copyright = "";
91
public string copyright{
100
private string[] _documenters;
101
public string[] documenters{
106
_documenters = value;
110
private string[] _donations;
111
public string[] donations{
120
private string _license = "";
121
public string license{
130
private Gdk.Pixbuf _logo;
131
public Gdk.Pixbuf logo{
140
private string _program_name = "";
141
public string program_name{
143
return _program_name;
146
_program_name = value;
150
private string[] _translators;
151
public string[] translators{
156
_translators = value;
160
private string[] _third_party;
161
public string[] third_party{
166
_third_party = value;
170
private string _version = "";
171
public string version{
180
private string _website = "";
181
public string website{
190
private string _website_label = "";
191
public string website_label{
193
return _website_label;
196
_website_label = value;
200
public AboutWindow() {
201
window_position = WindowPosition.CENTER_ON_PARENT;
202
set_destroy_with_parent (true);
204
skip_taskbar_hint = false;
205
set_default_size (450, 400);
207
vbox_main = get_content_area();
208
vbox_main.margin = 6;
209
vbox_main.spacing = 6;
211
vbox_logo = new Box(Orientation.VERTICAL,0);
212
vbox_main.add(vbox_logo);
214
vbox_credits = new Box(Orientation.VERTICAL,0);
215
vbox_credits.no_show_all = true;
216
vbox_main.add(vbox_credits);
218
vbox_lines = new Box(Orientation.VERTICAL,0);
219
vbox_lines.margin_top = 10;
222
img_logo = new Gtk.Image();
223
img_logo.margin_top = 6;
224
img_logo.margin_bottom = 6;
225
vbox_logo.add(img_logo);
228
lbl_program_name = new Label("");
229
lbl_program_name.set_use_markup(true);
230
vbox_logo.add(lbl_program_name);
233
lbl_version = new Label("");
234
lbl_version.set_use_markup(true);
235
lbl_version.margin_top = 5;
236
vbox_logo.add(lbl_version);
239
lbl_comments = new Label("");
240
lbl_comments.set_use_markup(true);
241
lbl_comments.margin_top = 10;
242
vbox_logo.add(lbl_comments);
245
lbtn_website = new LinkButton("");
246
lbtn_website.margin_top = 5;
247
vbox_logo.add(lbtn_website);
249
lbtn_website.activate_link.connect(()=>{
251
return Gtk.show_uri(null, lbtn_website.uri, Gdk.CURRENT_TIME);
259
lbl_copyright = new Label("");
260
lbl_copyright.set_use_markup(true);
261
lbl_copyright.margin_top = 5;
262
vbox_logo.add(lbl_copyright);
265
var spacer_bottom = new Label("");
266
spacer_bottom.margin_top = 20;
267
vbox_logo.add(spacer_bottom);
270
var sw_credits = new ScrolledWindow(null, null);
271
sw_credits.set_shadow_type(ShadowType.ETCHED_IN);
272
sw_credits.expand = true;
274
vbox_credits.add(sw_credits);
275
sw_credits.add(vbox_lines);
277
//hbox_commands --------------------------------------------------
279
hbox_action = (Box) get_action_area();
282
btn_credits = new Button.with_label(" " + _("Credits"));
283
btn_credits.set_image (new Image.from_stock ("gtk-about", IconSize.MENU));
284
hbox_action.add(btn_credits);
286
btn_credits.clicked.connect(()=>{
287
vbox_logo.visible = !(vbox_logo.visible);
288
vbox_credits.visible = !(vbox_credits.visible);
290
if ((vbox_credits.visible)&&(!sw_credits.visible)){
291
sw_credits.show_all();
294
if (vbox_credits.visible){
295
btn_credits.label = " " + _("Back");
296
btn_credits.set_image (new Image.from_stock ("gtk-go-back", IconSize.MENU));
299
btn_credits.label = " " + _("Credits");
300
btn_credits.set_image (new Image.from_stock ("gtk-about", IconSize.MENU));
305
btn_close = new Button.with_label(" " + _("Close"));
306
btn_close.set_image (new Image.from_stock ("gtk-close", IconSize.MENU));
307
hbox_action.add(btn_close);
309
btn_close.clicked.connect(()=>{ this.destroy(); });
312
public void initialize() {
313
title = program_name;
314
img_logo.pixbuf = logo.scale_simple(128,128,Gdk.InterpType.HYPER);
315
lbl_program_name.label = "<span size='larger'>%s</span>".printf(program_name);
316
lbl_version.label = "v%s".printf(version);
317
lbl_comments.label = "%s".printf(comments);
318
lbtn_website.uri = website;
319
lbtn_website.label = website_label;
320
//lbl_copyright.label = "<span size='smaller'>%s</span>".printf(copyright);
321
lbl_copyright.label = "<span>%s</span>".printf(copyright);
323
if (authors.length > 0){
324
add_header("<b>%s</b>\n".printf(_("Authors")));
325
foreach(string name in authors){
326
add_line("%s\n".printf(name));
331
if (contributors.length > 0){
332
add_header("<b>%s</b>\n".printf(_("Contributions")));
333
foreach(string name in contributors){
334
add_line("%s\n".printf(name));
339
if (third_party.length > 0){
340
add_header("<b>%s</b>\n".printf(_("Third Party Tools")));
341
foreach(string name in third_party){
342
add_line("%s\n".printf(name));
347
if (artists.length > 0){
348
add_header("<b>%s</b>\n".printf(_("Artists")));
349
foreach(string name in artists){
350
add_line("%s\n".printf(name));
355
if (translators.length > 0){
356
add_header("<b>%s</b>\n".printf(_("Translators")));
357
foreach(string name in translators){
358
add_line("%s\n".printf(name));
363
if (documenters.length > 0){
364
add_header("<b>%s</b>\n".printf(_("Documenters")));
365
foreach(string name in documenters){
366
add_line("%s\n".printf(name));
371
if (donations.length > 0){
372
add_header("<b>%s</b>\n".printf(_("Donations")));
373
foreach(string name in donations){
374
add_line("%s\n".printf(name));
379
if (vbox_lines.get_children().length() == 0){
380
btn_credits.visible = false;
384
public void add_line(string text, bool escape_html_chars = true){
386
if (text.split(":").length >= 2){
387
var link = new LinkButton(escape_html(text.split(":")[0]));
388
vbox_lines.add(link);
390
string val = text[text.index_of(":") + 1:text.length];
391
if (val.contains("@")){
392
link.uri = "mailto:" + val;
394
else if(val.has_prefix("http://")){
398
link.uri = "http://" + val;
401
link.activate_link.connect(()=>{
403
return Gtk.show_uri(null, link.uri, Gdk.CURRENT_TIME);
412
if (escape_html_chars){
413
txt = escape_html(text);
416
var lbl = new Label(txt);
417
lbl.set_use_markup(true);
418
lbl.valign = Align.START;
420
lbl.wrap_mode = Pango.WrapMode.WORD;
425
public void add_header(string text){
426
add_line(text, false);