🔧 Use Adw.AboutWindow if available

This commit is contained in:
Simon Schneegans
2023-01-07 20:42:36 +01:00
parent 7739504d76
commit 0d2ff4f5cd
2 changed files with 139 additions and 35 deletions
+71 -18
View File
@@ -320,26 +320,78 @@ var PreferencesDialog = class PreferencesDialog {
}); });
const sponsors = this._getJSONResource('/credits/sponsors.json'); const sponsors = this._getJSONResource('/credits/sponsors.json');
let dialog;
// We try to use the special Adw.AboutWindow if it is available.
if (utils.isADW() && Adw.AboutWindow) {
let formatSponsors = (sponsors) => {
return sponsors.map(s => {
if (s.url == '')
return s.name;
else
return `${s.name} ${s.url}`;
});
};
dialog = new Adw.AboutWindow({transient_for: window, modal: true});
dialog.set_application_icon('burn-my-windows-symbolic');
dialog.set_application_name('Burn-My-Windows');
dialog.set_version(`${Me.metadata.version}`);
dialog.set_developer_name('Simon Schneegans');
dialog.set_issue_url('https://github.com/Schneegans/Burn-My-Windows/issues');
if (sponsors.gold.length > 0) {
dialog.add_credit_section(_('Gold Sponsors'),
formatSponsors(sponsors.gold));
}
if (sponsors.silver.length > 0) {
dialog.add_credit_section(_('Silver Sponsors'),
formatSponsors(sponsors.silver));
}
if (sponsors.bronze.length > 0) {
dialog.add_credit_section(_('Bronze Sponsors'),
formatSponsors(sponsors.bronze));
}
if (sponsors.past.length > 0) {
dialog.add_credit_section(_('Past Sponsors'),
formatSponsors(sponsors.past));
}
} else {
let formatSponsors = (sponsors) => {
return sponsors.map(s => {
if (s.url == '')
return s.name;
else
return `<a href="${s.url}">${s.name}</a>`;
});
};
dialog = new Gtk.AboutDialog({transient_for: window, modal: true});
dialog.set_logo_icon_name('burn-my-windows-symbolic');
dialog.set_program_name(`Burn-My-Windows ${Me.metadata.version}`);
dialog.set_authors(['Simon Schneegans']);
if (sponsors.gold.length > 0) {
dialog.add_credit_section(_('Gold Sponsors'),
formatSponsors(sponsors.gold));
}
if (sponsors.silver.length > 0) {
dialog.add_credit_section(_('Silver Sponsors'),
formatSponsors(sponsors.silver));
}
if (sponsors.bronze.length > 0) {
dialog.add_credit_section(_('Bronze Sponsors'),
formatSponsors(sponsors.bronze));
}
if (sponsors.past.length > 0) {
dialog.add_credit_section(_('Past Sponsors'),
formatSponsors(sponsors.past));
}
}
const dialog = new Gtk.AboutDialog({transient_for: window, modal: true});
dialog.set_logo_icon_name('burn-my-windows-symbolic');
dialog.set_program_name(`Burn-My-Windows ${Me.metadata.version}`);
dialog.set_website('https://github.com/Schneegans/Burn-My-Windows');
dialog.set_authors(['Simon Schneegans']);
dialog.set_copyright('© 2022 Simon Schneegans');
dialog.set_translator_credits([...translators].join('\n')); dialog.set_translator_credits([...translators].join('\n'));
if (sponsors.gold.length > 0) { dialog.set_copyright('© 2022 Simon Schneegans');
dialog.add_credit_section(_('Gold Sponsors'), sponsors.gold); dialog.set_website('https://github.com/Schneegans/Burn-My-Windows');
}
if (sponsors.silver.length > 0) {
dialog.add_credit_section(_('Silver Sponsors'), sponsors.silver);
}
if (sponsors.bronze.length > 0) {
dialog.add_credit_section(_('Bronze Sponsors'), sponsors.bronze);
}
if (sponsors.past.length > 0) {
dialog.add_credit_section(_('Past Sponsors'), sponsors.past);
}
dialog.set_license_type(Gtk.License.GPL_3_0); dialog.set_license_type(Gtk.License.GPL_3_0);
if (utils.isGTK4()) { if (utils.isGTK4()) {
@@ -348,6 +400,7 @@ var PreferencesDialog = class PreferencesDialog {
dialog.show_all(); dialog.show_all();
} }
}); });
group.add_action(aboutAction); group.add_action(aboutAction);
} }
+68 -17
View File
@@ -1,27 +1,78 @@
{ {
"gold": [ "gold": [
"<a href='https://github.com/D3vil0p3r'>D3vil0p3r</a>", {
"Maxence Sebald", "name": "D3vil0p3r",
"<a href='https://github.com/dennis1248'>Dennis ten Hoove</a>" "url": "https://github.com/D3vil0p3r"
},
{
"name": "Maxence Sebald",
"url": ""
},
{
"name": "Dennis ten Hoove",
"url": "https://github.com/dennis1248"
}
], ],
"silver": [ "silver": [
"<a href='https://github.com/danielheadbang'>@danielheadbang</a>", {
"<a href='https://github.com/MRR-dev'>@MRR-dev</a>", "name": "@danielheadbang",
"<a href='https://github.com/castrojo'>Jorge Castro</a>" "url": "https://github.com/danielheadbang"
},
{
"name": "@MRR-dev",
"url": "https://github.com/MRR-dev"
},
{
"name": "Jorge Castro",
"url": "https://github.com/castrojo"
}
], ],
"bronze": [ "bronze": [
"<a href='https://github.com/AngelBrielez'>Angel Brielez</a>" {
"name": "Angel Brielez",
"url": "https://github.com/AngelBrielez"
}
], ],
"past": [ "past": [
"<a href='https://github.com/taconomix'>@taconomix</a>", {
"<a href='https://github.com/enolive'>@enolive</a>", "name": "@taconomix",
"<a href='https://github.com/Aggraxis'>@Aggraxis</a>", "url": "https://github.com/taconomix"
"<a href='https://twitter.com/tjiiik'>tj3k</a>", },
"<a href='https://github.com/wolfyrion'>@wolfyrion</a>", {
"<a href='https://github.com/MrTomRod'>@MrTomRod</a>", "name": "@enolive",
"Pouhiou", "url": "https://github.com/enolive"
"DAPREMONT Christophe", },
"<a href='https://github.com/manero6'>@manero6</a>", {
"<a href='https://github.com/RickStanley'>@RickStanley</a>" "name": "@Aggraxis",
"url": "https://github.com/Aggraxis"
},
{
"name": "tj3k",
"url": "https://twitter.com/tjiiik"
},
{
"name": "@wolfyrion",
"url": "https://github.com/wolfyrion"
},
{
"name": "@MrTomRod",
"url": "https://github.com/MrTomRod"
},
{
"name": "Pouhiou",
"url": ""
},
{
"name": "DAPREMONT Christophe",
"url": ""
},
{
"name": "@manero6",
"url": "https://github.com/manero6"
},
{
"name": "@RickStanley",
"url": "https://github.com/RickStanley"
}
] ]
} }