Skip to content
API Documentation
BastionGuard™
DonatePage.cpp
Go to the documentation of this file.
1/*
2 * BastionGuard™
3 * Copyright (C) 2025–2026 Calogero Scarnà
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 3.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 *
17 * BastionGuard™ is a trademark of Calogero Scarnà.
18 * The BastionGuard™ name and branding are not licensed under the GPL.
19 */
20
21#include "Resource.hpp"
22#include "DonatePage.hpp"
23#include <giomm.h>
24#include <iostream>
25#include <glib/gi18n.h>
26
28: Gtk::Box(Gtk::Orientation::VERTICAL, 12)
29{
30 set_margin(20);
31
32 auto lbl_title = Gtk::make_managed<Gtk::Label>("<b>" + Glib::ustring(_("Sostieni BastionGuard")) + " Endpoint </b>");
33 lbl_title->set_use_markup(true);
34 lbl_title->set_halign(Gtk::Align::CENTER);
35 append(*lbl_title);
36
37
38 auto lbl_desc = Gtk::make_managed<Gtk::Label>(
39 _("Grazie al tuo contributo possiamo migliorare BastionGuard, "
40 "basta un piccolo gesto. Il contributo è prettamente volontario, "
41 "vi chiediamo solo di sostenerci a portare avanti qualcosa del tutto gratuito per voi.")
42 );
43 lbl_desc->set_wrap(true);
44 lbl_desc->set_justify(Gtk::Justification::CENTER);
45 lbl_desc->set_margin(10);
46 append(*lbl_desc);
47
48
49 auto picture = Gtk::make_managed<Gtk::Picture>();
50 try {
51 picture->set_file(Gio::File::create_for_path(resource("donate.png")));
52 } catch (...) {
53 std::cerr << _("❌ Impossibile caricare l'immagine data/donate.png") << "\n";
54 }
55
56 picture->set_content_fit(Gtk::ContentFit::CONTAIN);
57 picture->set_size_request(350, 121);
58 picture->set_halign(Gtk::Align::CENTER);
59 picture->set_valign(Gtk::Align::CENTER);
60 picture->set_margin(10);
61
62 append(*picture);
63
64
65 auto btn_box = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::HORIZONTAL, 6);
66
67 auto icon = Gtk::make_managed<Gtk::Image>();
68 icon->set_from_icon_name("emblem-favorite");
69 btn_box->append(*icon);
70
71 auto lbl = Gtk::make_managed<Gtk::Label>(_("Vai alla donazione"));
72 btn_box->append(*lbl);
73
74 auto btn_donate = Gtk::make_managed<Gtk::Button>();
75 btn_donate->set_child(*btn_box);
76 btn_donate->set_halign(Gtk::Align::CENTER);
77 btn_donate->signal_clicked().connect(sigc::mem_fun(*this, &DonatePage::on_open_donate));
78
79 append(*btn_donate);
80}
81
83 try {
84 Gio::AppInfo::launch_default_for_uri("https://www.paypal.com/donate/?hosted_button_id=XR4622XJZMKGN");
85 } catch (const Glib::Error& ex) {
86 std::cerr << _("❌ Errore apertura link donazione: ") << ex.what() << "\n";
87 }
88}
#define _(s)
void on_open_donate()
std::string resource(const std::string &rel)
Definition Resource.hpp:31