Skip to content
API Documentation
BastionGuard™
PasswordSearchRow.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 "PasswordSearchRow.hpp"
22
23#include <glibmm/i18n.h>
24
26: entry_(entry),
27 rootBox(Gtk::Orientation::VERTICAL, 0),
28 headerBox(Gtk::Orientation::HORIZONTAL, 8),
29 bodyBox(Gtk::Orientation::VERTICAL, 6),
30 titleLabel("🔐 " + entry.name),
31 expandIconLabel("▼"),
32 usernameLabel(_("Utente: ") + entry.username),
33 urlLabel(_("URL: ") + entry.url),
34 updatedLabel(_("Aggiornato: ") + entry.updated_at),
35 actionsBox(Gtk::Orientation::HORIZONTAL, 6),
36 revealButton(_("Mostra password")),
37 editButton(_("Modifica")),
38 deleteButton(_("Elimina"))
39{
40 buildUi();
42}
43
45 set_hexpand(true);
46 set_margin_top(4);
47 set_margin_bottom(4);
48 set_margin_start(4);
49 set_margin_end(4);
50
51 titleLabel.set_xalign(0.0f);
52 titleLabel.set_hexpand(true);
53
54 expandIconLabel.set_xalign(1.0f);
55 expandIconLabel.set_margin_start(6);
56
57 headerBox.set_margin_top(6);
58 headerBox.set_margin_bottom(6);
59 headerBox.set_margin_start(6);
60 headerBox.set_margin_end(6);
61 headerBox.append(titleLabel);
63
64 usernameLabel.set_xalign(0.0f);
65 urlLabel.set_xalign(0.0f);
66 updatedLabel.set_xalign(0.0f);
67
68 deleteButton.add_css_class("btn-danger");
69
71 actionsBox.append(editButton);
73
74 bodyBox.set_margin_top(6);
75 bodyBox.set_margin_bottom(6);
76 bodyBox.set_margin_start(6);
77 bodyBox.set_margin_end(6);
78 bodyBox.append(usernameLabel);
79 bodyBox.append(urlLabel);
80 bodyBox.append(updatedLabel);
81 bodyBox.append(actionsBox);
82
83 revealer.set_transition_type(Gtk::RevealerTransitionType::SLIDE_DOWN);
84 revealer.set_transition_duration(180);
85 revealer.set_reveal_child(false);
86 revealer.set_child(bodyBox);
87
88 rootBox.append(headerBox);
89 rootBox.append(revealer);
90
91 set_child(rootBox);
92}
93
95 auto click = Gtk::GestureClick::create();
96 click->signal_pressed().connect([this](int n_press, double, double) {
97 if (n_press == 1) {
99 }
100 });
101 headerBox.add_controller(click);
102
103 revealButton.signal_clicked().connect([this]() {
104 signalReveal_.emit(entry_);
105 });
106
107 editButton.signal_clicked().connect([this]() {
108 signalEdit_.emit(entry_);
109 });
110
111 deleteButton.signal_clicked().connect([this]() {
112 signalDelete_.emit(entry_);
113 });
114}
115
117 const bool expanded = revealer.get_reveal_child();
118 revealer.set_reveal_child(!expanded);
119 expandIconLabel.set_text(expanded ? "▼" : "▲");
120}
121
123 return signalReveal_;
124}
125
126sigc::signal<void(const PasswordEntry&)> PasswordSearchRow::signal_edit() {
127 return signalEdit_;
128}
129
131 return signalDelete_;
132}
#define _(s)
sigc::signal< void(const PasswordEntry &)> signal_delete()
sigc::signal< void(const PasswordEntry &)> signalDelete_
sigc::signal< void(const PasswordEntry &)> signalReveal_
sigc::signal< void(const PasswordEntry &)> signal_edit()
PasswordSearchRow(const PasswordEntry &entry)
sigc::signal< void(const PasswordEntry &)> signalEdit_
sigc::signal< void(const PasswordEntry &)> signal_reveal()