Skip to content
API Documentation
BastionGuard™
SettingsWindow Class Reference

#include <SettingsWindow.hpp>

Inheritance diagram for SettingsWindow:

Public Types

enum  Tabs { BACKUP_TYPE = 0 , BACKUP_DEVICE = 1 , SCHEDULE = 2 , EXCLUDE = 3 }

Public Member Functions

 SettingsWindow (ClamdConfig &config)
signal void request_close ()
 SettingsWindow (bool embedded=false)
Gtk.Widget detach_root_widget ()
void reload_themed_icons ()

Private Member Functions

void build_headerbar ()
void build_sidebar (ClamdConfig &config)
Gtk::Button * make_group_button (const std::string &icon_path, const std::string &label_text, Gtk::Box **out_submenu=nullptr)
Gtk::Button * make_leaf_button (const std::string &label_text, bool indent=false, Gtk::Box *parent_submenu=nullptr)
void activate_button (Gtk::Button *btn)
void build_ui ()
void build_sidebar ()
void build_content ()
void build_pages ()
void connect_signals ()
Gtk.Button create_nav_button (string icon_name, string text)
Gee.ArrayList< string > get_tab_order ()
int get_current_tab_index ()
void activate_tab_by_name (string name)
void activate_relative_tab (int delta)
void update_bottom_navigation ()
void activate_tab (string name, Gtk.Button active_button, string title_text)
void clear_nav_selection ()
bool init_delayed ()
bool on_close_request ()
void save_changes ()
Gtk.Image themed_icon (string icon_name, int size)

Private Attributes

Gtk::Box mainBox_ {Gtk::Orientation::HORIZONTAL, 0}
Gtk::Stack stack_
SettingsPage * settingsPage_ = nullptr
Gtk::Box * sidebar_box_ = nullptr
std::vector< Gtk::Button * > all_leaf_buttons_
std::map< Gtk::Button *, Gtk::Box * > button_submenu_
Gtk::Button * active_button_ = nullptr
int active_page_ = 0
Gtk.Box root_box
Gtk.Box sidebar
Gtk.Box content_box
Gtk.Box content_header_box
Gtk.Box content_body_box
Gtk.Box bottom_bar
Gtk.Stack stack
SnapshotBackendBox backend_box
BackupDeviceBox backup_dev_box
ScheduleBox schedule_box
ExcludeBox exclude_box
UsersBox users_box
MiscBox misc_box
Gtk.Button btn_type
Gtk.Button btn_location
Gtk.Button btn_schedule
Gtk.Button btn_users
Gtk.Button btn_filters
Gtk.Button btn_misc
Gtk.Button btn_close
Gtk.Button btn_prev
Gtk.Button btn_next
Gtk.Label lbl_page_title
Gee.ArrayList< Gtk.Button > nav_buttons
uint tmr_init
int def_width = 1100
int def_height = 760
bool embedded_mode = false
Gee.ArrayList< Gtk.Image > themed_img_list = new Gee.ArrayList<Gtk.Image>()
Gee.ArrayList< string > themed_img_name = new Gee.ArrayList<string>()
Gee.ArrayList< int > themed_img_size = new Gee.ArrayList<int>()

Detailed Description

Definition at line 29 of file SettingsWindow.hpp.

Member Enumeration Documentation

◆ Tabs

Enumerator
BACKUP_TYPE 
BACKUP_DEVICE 
SCHEDULE 
EXCLUDE 

Definition at line 493 of file SettingsWindow.vala.

493 {
494 BACKUP_TYPE = 0,
495 BACKUP_DEVICE = 1,
496 SCHEDULE = 2,
497 EXCLUDE = 3
498 }

Constructor & Destructor Documentation

◆ SettingsWindow() [1/2]

SettingsWindow::SettingsWindow ( ClamdConfig & config)
explicit

Definition at line 29 of file SettingsWindow.cpp.

30{
31 set_title("");
32 set_default_size(600, 400);
33 set_modal(true);
34 set_resizable(true);
35
37
38 stack_.get_style_context()->add_class("content");
39 stack_.set_transition_type(Gtk::StackTransitionType::SLIDE_LEFT_RIGHT);
40 stack_.set_transition_duration(220);
41 stack_.set_interpolate_size(true);
42
43 settingsPage_ = Gtk::make_managed<SettingsPage>(config);
45 settingsPage_->set_hexpand(true);
46 settingsPage_->set_vexpand(true);
47
48 stack_.add(*settingsPage_, "settings_root");
49
50 mainBox_.get_style_context()->add_class("settings-main");
51 build_sidebar(config);
52 mainBox_.append(stack_);
53 stack_.set_hexpand(true);
54 stack_.set_vexpand(true);
55 mainBox_.set_margin(0);
56 mainBox_.set_margin_top(0);
57 mainBox_.set_margin_bottom(0);
58 mainBox_.set_margin_start(0);
59 mainBox_.set_margin_end(0);
60
61 mainBox_.set_hexpand(true);
62 mainBox_.set_vexpand(true);
63 set_child(mainBox_);
64 get_style_context()->add_class("settings-window");
65
66 load_style();
67
68 signal_map().connect([this]() {
69 if (global_css)
70 get_style_context()->add_provider(global_css, GTK_STYLE_PROVIDER_PRIORITY_USER);
71 });
72
73 signal_hide().connect([this]() {
74 active_button_ = nullptr;
75 active_page_ = 0;
76 });
77
78 signal_show().connect([this]() {
80 if (!all_leaf_buttons_.empty())
82 });
83}
void goto_page(int n)
void set_notebook_no_tabs()
std::vector< Gtk::Button * > all_leaf_buttons_
SettingsPage * settingsPage_
Gtk::Button * active_button_
void build_sidebar(ClamdConfig &config)
void activate_button(Gtk::Button *btn)
void load_style()
Glib::RefPtr< Gtk::CssProvider > global_css

References activate_button(), active_button_, active_page_, all_leaf_buttons_, build_headerbar(), build_sidebar(), global_css, SettingsPage::goto_page(), load_style(), mainBox_, SettingsPage::set_notebook_no_tabs(), settingsPage_, and stack_.

Referenced by MainWindow::init_settings_page(), and MainWindow::open_settings_window().

◆ SettingsWindow() [2/2]

SettingsWindow.SettingsWindow ( bool embedded = false)
inline

Definition at line 78 of file SettingsWindow.vala.

78 {
79 embedded_mode = embedded;
80
81 log_debug("SettingsWindow: SettingsWindow()");
82
83 this.title = _("Settings");
84 if (!embedded_mode) {
85 this.modal = true;
86 }
87 this.set_icon_name("bastionguard-backup");
88 this.set_default_size(def_width, def_height);
89 this.set_default_size(def_width, def_height);
90 this.set_titlebar(HeaderFactory.create_main_headerbar(this, 230));
91 if (!embedded_mode)
92 this.close_request.connect(on_close_request);
93
94 nav_buttons = new Gee.ArrayList<Gtk.Button>();
95
96 build_ui();
99
100 if (!embedded_mode)
101 show();
102
103 activate_tab("type", btn_type, _("Type"));
104
105 tmr_init = Timeout.add(100, init_delayed);
106
107 log_debug("SettingsWindow: SettingsWindow(): exit");
108 }
#define _(s)
Gtk.Button btn_type
void activate_tab(string name, Gtk.Button active_button, string title_text)
Gee.ArrayList< Gtk.Button > nav_buttons
void log_debug(string message)

References _, activate_tab(), btn_type, build_pages(), build_ui(), connect_signals(), HeaderFactory.create_main_headerbar(), def_height, def_width, embedded_mode, init_delayed(), TeeJee.Logging.log_debug(), nav_buttons, on_close_request(), and tmr_init.

Member Function Documentation

◆ activate_button()

void SettingsWindow::activate_button ( Gtk::Button * btn)
private

Definition at line 159 of file SettingsWindow.cpp.

160{
161 active_button_ = btn;
162
163 for (auto* b : all_leaf_buttons_)
164 b->get_style_context()->remove_class("active-sidebar-button");
165
166 if (btn)
167 btn->get_style_context()->add_class("active-sidebar-button");
168
169 Gtk::Box* active_sub = button_submenu_.count(btn) ? button_submenu_.at(btn) : nullptr;
170
171 std::set<Gtk::Box*> all_submenus;
172 for (auto& [b, sub] : button_submenu_)
173 if (sub)
174 all_submenus.insert(sub);
175
176 for (auto* sub : all_submenus) {
177 const bool should_open = (sub == active_sub);
178 sub->set_visible(should_open);
179
180 if (auto* parent_box = dynamic_cast<Gtk::Box*>(sub->get_parent())) {
181 Gtk::Widget* prev = nullptr;
182
183 for (auto* child = parent_box->get_first_child();
184 child != nullptr;
185 child = child->get_next_sibling())
186 {
187 if (child == sub) {
188 if (auto* grp_btn = dynamic_cast<Gtk::Button*>(prev)) {
189 if (auto* outer = dynamic_cast<Gtk::Box*>(grp_btn->get_child())) {
190 Gtk::Widget* last = nullptr;
191 for (auto* w = outer->get_first_child(); w; w = w->get_next_sibling())
192 last = w;
193
194 if (auto* chev = dynamic_cast<Gtk::Label*>(last))
195 chev->set_text(should_open ? "▾" : "▸");
196 }
197 }
198 break;
199 }
200 prev = child;
201 }
202 }
203 }
204}
std::map< Gtk::Button *, Gtk::Box * > button_submenu_

References active_button_, all_leaf_buttons_, and button_submenu_.

Referenced by build_sidebar(), and SettingsWindow().

◆ activate_relative_tab()

void SettingsWindow.activate_relative_tab ( int delta)
inlineprivate

Definition at line 424 of file SettingsWindow.vala.

424 {
425 var order = get_tab_order();
426 int index = get_current_tab_index();
427 int target = index + delta;
428 if (target < 0 || target >= order.size)
429 return;
430 activate_tab_by_name(order[target]);
431 }
void activate_tab_by_name(string name)
Gee.ArrayList< string > get_tab_order()

References activate_tab_by_name(), get_current_tab_index(), and get_tab_order().

Referenced by build_content().

◆ activate_tab()

void SettingsWindow.activate_tab ( string name,
Gtk.Button active_button,
string title_text )
inlineprivate

Definition at line 440 of file SettingsWindow.vala.

440 {
441
443
444 active_button.get_style_context().add_class("active-sidebar-button");
445 lbl_page_title.label = title_text;
446
447 if (stack != null) {
448 stack.set_visible_child_name(name);
449 }
450
452 }
void update_bottom_navigation()

References clear_nav_selection(), stack, and update_bottom_navigation().

Referenced by activate_tab_by_name(), connect_signals(), init_delayed(), and SettingsWindow().

◆ activate_tab_by_name()

void SettingsWindow.activate_tab_by_name ( string name)
inlineprivate

Definition at line 401 of file SettingsWindow.vala.

401 {
402 switch (name) {
403 case "type":
404 activate_tab("type", btn_type, _("Type"));
405 break;
406 case "location":
407 activate_tab("location", btn_location, _("Location"));
408 break;
409 case "schedule":
410 activate_tab("schedule", btn_schedule, _("Schedule"));
411 break;
412 case "users":
413 activate_tab("users", btn_users, _("Users"));
414 break;
415 case "filters":
416 activate_tab("filters", btn_filters, _("Filters"));
417 break;
418 case "misc":
419 activate_tab("misc", btn_misc, _("Misc"));
420 break;
421 }
422 }
Gtk.Button btn_schedule
Gtk.Button btn_filters
Gtk.Button btn_users
Gtk.Button btn_location
Gtk.Button btn_misc

References _, activate_tab(), btn_filters, btn_location, btn_misc, btn_schedule, btn_type, and btn_users.

Referenced by activate_relative_tab().

◆ build_content()

void SettingsWindow.build_content ( )
inlineprivate

Definition at line 190 of file SettingsWindow.vala.

190 {
191
192 content_box = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
193 content_box.hexpand = true;
194 content_box.vexpand = true;
195 content_box.halign = Gtk.Align.FILL;
196 content_box.valign = Gtk.Align.FILL;
197 content_box.get_style_context().add_class("content");
198
199 content_header_box = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
200 content_header_box.margin_start = 20;
201 content_header_box.margin_end = 20;
202 content_header_box.margin_top = 20;
203 content_header_box.margin_bottom = 20;
204 content_header_box.margin_bottom = 8;
205
206 lbl_page_title = new Gtk.Label(_("Settings"));
207 lbl_page_title.xalign = 0.0f;
208 lbl_page_title.get_style_context().add_class("title");
209
211
212 content_body_box = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
213 content_body_box.hexpand = true;
214 content_body_box.vexpand = true;
215 content_body_box.halign = Gtk.Align.FILL;
216 content_body_box.valign = Gtk.Align.FILL;
217 content_body_box.margin_start = 20;
218 content_body_box.margin_end = 20;
219 content_body_box.margin_bottom = 12;
220
221 stack = new Gtk.Stack();
222 stack.hexpand = true;
223 stack.vexpand = true;
224 stack.halign = Gtk.Align.FILL;
225 stack.valign = Gtk.Align.FILL;
226 stack.set_transition_duration(120);
227 stack.set_transition_type(Gtk.StackTransitionType.SLIDE_UP_DOWN);
228
229 content_body_box.append(stack);
230
231 bottom_bar = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 8);
232 bottom_bar.margin_start = 20;
233 bottom_bar.margin_end = 20;
234 bottom_bar.margin_bottom = 20;
235 bottom_bar.halign = Gtk.Align.END;
236
237 var btn_cancel = new Gtk.Button.with_label(_("Cancel"));
238 btn_cancel.set_size_request(110, -1);
239 btn_cancel.get_style_context().add_class("btn-cancel");
240
241 btn_prev = new Gtk.Button.with_label(_("Previous"));
242 btn_prev.set_size_request(110, -1);
243 btn_prev.get_style_context().add_class("btn-back");
244
245 btn_next = new Gtk.Button.with_label(_("Next"));
246 btn_next.set_size_request(110, -1);
247 btn_next.get_style_context().add_class("btn-next");
248
249 var btn_ok = new Gtk.Button.with_label(_("OK"));
250 btn_ok.set_size_request(110, -1);
251 btn_ok.get_style_context().add_class("btn-finish");
252 btn_ok.get_style_context().add_class("suggested-action");
253
254 bottom_bar.append(btn_cancel);
255 bottom_bar.append(btn_prev);
256 bottom_bar.append(btn_next);
257 bottom_bar.append(btn_ok);
258
259 btn_cancel.clicked.connect(() => {
261 else this.destroy();
262 });
263
264 btn_prev.clicked.connect(() => {
266 });
267
268 btn_next.clicked.connect(() => {
270 });
271
272 btn_ok.clicked.connect(() => {
273 save_changes();
275 else this.destroy();
276 });
277
280 content_box.append(bottom_bar);
281 }
Gtk.Button btn_next
signal void request_close()
Gtk.Box content_header_box
Gtk.Button btn_prev
void activate_relative_tab(int delta)
Gtk.Label lbl_page_title

References _, activate_relative_tab(), bottom_bar, btn_next, btn_prev, content_body_box, content_box, content_header_box, embedded_mode, lbl_page_title, request_close(), save_changes(), and stack.

Referenced by build_ui().

◆ build_headerbar()

void SettingsWindow::build_headerbar ( )
private

Definition at line 402 of file SettingsWindow.cpp.

403{
404 auto header = Gtk::make_managed<Gtk::HeaderBar>();
405 header->set_show_title_buttons(false);
406 header->set_decoration_layout("");
407 header->get_style_context()->add_class("custom-headerbar");
408
409 auto header_left = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::HORIZONTAL);
410 header_left->set_size_request(220, -1);
411 header_left->get_style_context()->add_class("header-left");
412
413 auto accent = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::VERTICAL);
414 accent->set_size_request(6, -1);
415 accent->get_style_context()->add_class("header-accent");
416 header_left->append(*accent);
417
418 header->pack_start(*header_left);
419
420 auto header_spacer = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::HORIZONTAL);
421 header_spacer->set_hexpand(true);
422 header->pack_start(*header_spacer);
423
424 auto header_right = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::HORIZONTAL);
425 header_right->get_style_context()->add_class("header-right");
426
427 try {
428 auto pix = Gdk::Pixbuf::create_from_file(resource("icon-close.png"), 32, 32, true);
429 auto btn_close = Gtk::make_managed<Gtk::Button>();
430 btn_close->set_child(*Gtk::make_managed<Gtk::Image>(pix));
431 btn_close->get_style_context()->add_class("header-button");
432 btn_close->signal_clicked().connect([this]() { this->close(); });
433 header_right->append(*btn_close);
434 } catch (...) {
435 std::cerr << _("⚠ Errore caricamento icona close") << "\n";
436 }
437
438 header->pack_end(*header_right);
439 set_titlebar(*header);
440}
Gtk.Button btn_close
std::string resource(const std::string &rel)
Definition Resource.hpp:31

References _, btn_close, and resource().

Referenced by SettingsWindow().

◆ build_pages()

void SettingsWindow.build_pages ( )
inlineprivate

Definition at line 283 of file SettingsWindow.vala.

283 {
284
286 stack.add_named(backend_box, "type");
287
289 stack.add_named(backup_dev_box, "location");
290
291 schedule_box = new ScheduleBox(this);
292 stack.add_named(schedule_box, "schedule");
293
294 exclude_box = new ExcludeBox(this);
295 users_box = new UsersBox(this, exclude_box, false);
297
298 misc_box = new MiscBox(this, false);
299
300 stack.add_named(users_box, "users");
301 stack.add_named(exclude_box, "filters");
302 stack.add_named(misc_box, "misc");
303 }
BackupDeviceBox(Gtk.Window _parent_window)
ExcludeBox(Gtk.Window _parent_window)
void set_users_box(UsersBox _users_box)
MiscBox(Gtk.Window _parent_window, bool _restore_mode)
Definition MiscBox.vala:21
ScheduleBox(Gtk.Window _parent_window)
BackupDeviceBox backup_dev_box
ScheduleBox schedule_box
ExcludeBox exclude_box
SnapshotBackendBox backend_box
SnapshotBackendBox(Gtk.Window _parent_window)
UsersBox(Gtk.Window _parent_window, ExcludeBox _exclude_box, bool _restore_mode)
Definition UsersBox.vala:26

References backend_box, backup_dev_box, BackupDeviceBox.BackupDeviceBox(), exclude_box, ExcludeBox.ExcludeBox(), misc_box, MiscBox.MiscBox(), schedule_box, ScheduleBox.ScheduleBox(), ExcludeBox.set_users_box(), SnapshotBackendBox.SnapshotBackendBox(), stack, users_box, and UsersBox.UsersBox().

Referenced by SettingsWindow().

◆ build_sidebar() [1/2]

void SettingsWindow.build_sidebar ( )
inlineprivate

Definition at line 126 of file SettingsWindow.vala.

126 {
127
128 sidebar = new Gtk.Box(Gtk.Orientation.VERTICAL, 12);
129 sidebar.set_size_request(230, -1);
130 sidebar.hexpand = false;
131 sidebar.vexpand = true;
132 sidebar.halign = Gtk.Align.FILL;
133 sidebar.valign = Gtk.Align.FILL;
134 sidebar.get_style_context().add_class("sidebar");
135
136 var sidebar_header = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 8);
137 sidebar_header.margin_start = 12;
138 sidebar_header.margin_end = 12;
139 sidebar_header.margin_top = 12;
140 sidebar_header.margin_bottom = 12;
141 sidebar_header.get_style_context().add_class("sidebar-header");
142
143 Gtk.Widget logo_widget;
144 try {
145 logo_widget = new Gtk.Image.from_pixbuf(IconManager.lookup("bastionguard-backup", 48));
146 }
147 catch (Error e) {
148 logo_widget = themed_icon("preferences-system-symbolic", 48);
149 }
150
151 var title = new Gtk.Label("BastionGuard™\nSettings");
152 title.xalign = 0.0f;
153 title.yalign = 0.5f;
154 title.wrap = true;
155 title.max_width_chars = 14;
156 title.get_style_context().add_class("sidebar-title");
157
158 sidebar_header.append(logo_widget);
159 sidebar_header.append(title);
160
161 btn_type = create_nav_button("document-properties-symbolic", _("Type"));
162 btn_location = create_nav_button("drive-harddisk-symbolic", _("Location"));
163 btn_schedule = create_nav_button("x-office-calendar-symbolic", _("Schedule"));
164 btn_users = create_nav_button("system-users-symbolic", _("Users"));
165 btn_filters = create_nav_button("view-filter-symbolic", _("Filters"));
166 btn_misc = create_nav_button("preferences-other-symbolic", _("Misc"));
167 btn_close = create_nav_button("dialog-information-symbolic", _("Close"));
168
169 sidebar.append(sidebar_header);
170 sidebar.append(btn_type);
171 sidebar.append(btn_location);
172 sidebar.append(btn_schedule);
173 sidebar.append(btn_users);
174 sidebar.append(btn_filters);
175 sidebar.append(btn_misc);
176
177 var spacer = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
178 spacer.hexpand = true;
179 spacer.vexpand = true;
180 spacer.halign = Gtk.Align.FILL;
181 spacer.valign = Gtk.Align.FILL;
182 sidebar.append(spacer);
183
184 btn_close.margin_bottom = 12;
185 btn_close.margin_start = 8;
186 btn_close.margin_end = 8;
187 sidebar.append(btn_close);
188 }
Gtk.Image themed_icon(string icon_name, int size)
Gtk.Button create_nav_button(string icon_name, string text)

References _, btn_close, btn_filters, btn_location, btn_misc, btn_schedule, btn_type, btn_users, create_nav_button(), Error, IconManager.lookup(), sidebar, and themed_icon().

◆ build_sidebar() [2/2]

void SettingsWindow::build_sidebar ( ClamdConfig & config)
private

Definition at line 206 of file SettingsWindow.cpp.

207{
208 sidebar_box_ = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::VERTICAL, 6);
209 sidebar_box_->set_size_request(220, -1);
210 sidebar_box_->get_style_context()->add_class("sidebar");
211 sidebar_box_->set_vexpand(true);
212
213 {
214 auto header = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::HORIZONTAL, 8);
215 header->get_style_context()->add_class("sidebar-header");
216
217 try {
218 auto pix = Gdk::Pixbuf::create_from_file(resource("logo-sidebar.png"), 48, 48, true);
219 header->append(*Gtk::make_managed<Gtk::Image>(pix));
220 } catch (...) {}
221
222 auto title_lbl = Gtk::make_managed<Gtk::Label>(_("Impostazioni"));
223 title_lbl->set_halign(Gtk::Align::START);
224 title_lbl->get_style_context()->add_class("sidebar-title");
225 header->append(*title_lbl);
226 sidebar_box_->append(*header);
227 }
228
229 {
230 auto sep = Gtk::make_managed<Gtk::Separator>(Gtk::Orientation::HORIZONTAL);
231 sep->get_style_context()->add_class("sidebar-separator");
232 sidebar_box_->append(*sep);
233 }
234
235 auto menu_box = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::VERTICAL, 2);
236 menu_box->set_margin_top(4);
237 menu_box->set_margin_bottom(4);
238 menu_box->set_vexpand(true);
239
240 auto go = [this](int idx) {
243 };
244
245 {
246 auto* btn = make_leaf_button(_("Base"), false, nullptr);
247 btn->signal_clicked().connect([this, btn, go]() {
248 activate_button(btn);
249 go(0);
250 });
251 menu_box->append(*btn);
252 }
253
254 {
255 auto* btn = make_leaf_button(_("Avanzate"), false, nullptr);
256 btn->signal_clicked().connect([this, btn, go]() {
257 activate_button(btn);
258 go(1);
259 });
260 menu_box->append(*btn);
261 }
262
263 {
264 Gtk::Box* submenu = nullptr;
265 auto* grp = make_group_button(resource("icons/ransomware.svg"),
266 _("Anti-Ransomware"),
267 &submenu);
268 menu_box->append(*grp);
269 menu_box->append(*submenu);
270
271 auto* sub_base = make_leaf_button(_("Base"), true, submenu);
272 sub_base->signal_clicked().connect([this, sub_base, go]() {
273 activate_button(sub_base);
274 go(2);
275 });
276 submenu->append(*sub_base);
277
278 auto* sub_adv = make_leaf_button(_("Avanzate"), true, submenu);
279 sub_adv->signal_clicked().connect([this, sub_adv, go]() {
280 activate_button(sub_adv);
281 go(3);
282 });
283 submenu->append(*sub_adv);
284 }
285
286 {
287 Gtk::Box* submenu = nullptr;
288 auto* grp = make_group_button(resource("icons/scan.svg"),
289 _("Anti-Phishing"),
290 &submenu);
291 menu_box->append(*grp);
292 menu_box->append(*submenu);
293
294 auto* sub_prot = make_leaf_button(_("Protezione"), true, submenu);
295 sub_prot->signal_clicked().connect([this, sub_prot, go]() {
296 activate_button(sub_prot);
297 go(4);
298 });
299 submenu->append(*sub_prot);
300
301 auto* sub_wl = make_leaf_button(_("Whitelist / Blacklist"), true, submenu);
302 sub_wl->signal_clicked().connect([this, sub_wl, go]() {
303 activate_button(sub_wl);
304 go(5);
305 });
306 submenu->append(*sub_wl);
307 }
308
309 {
310 Gtk::Box* submenu = nullptr;
311 auto* grp = make_group_button(resource("icons/payments.svg"),
312 _("Pagamenti Sicuri"),
313 &submenu);
314 menu_box->append(*grp);
315 menu_box->append(*submenu);
316
317 auto* sub_pay = make_leaf_button(_("Domini Pagamenti"), true, submenu);
318 sub_pay->signal_clicked().connect([this, sub_pay, go]() {
319 activate_button(sub_pay);
320 go(6);
321 });
322 submenu->append(*sub_pay);
323
324 auto* sub_bypass = make_leaf_button(_("Bypass Proxy"), true, submenu);
325 sub_bypass->signal_clicked().connect([this, sub_bypass, go]() {
326 activate_button(sub_bypass);
327 go(7);
328 });
329 submenu->append(*sub_bypass);
330 }
331
332 {
333 Gtk::Box* submenu = nullptr;
334 auto* grp = make_group_button(resource("icons/settings.svg"),
335 _("Servizi"),
336 &submenu);
337 menu_box->append(*grp);
338 menu_box->append(*submenu);
339
340 auto* sub_user = make_leaf_button(_("Servizi Utente"), true, submenu);
341 sub_user->signal_clicked().connect([this, sub_user, go]() {
342 activate_button(sub_user);
343 go(8);
344 });
345 submenu->append(*sub_user);
346
347 auto* sub_sys = make_leaf_button(_("Servizi Sistema"), true, submenu);
348 sub_sys->signal_clicked().connect([this, sub_sys, go]() {
349 activate_button(sub_sys);
350 go(10);
351 });
352 submenu->append(*sub_sys);
353 }
354
355 {
356 auto* btn = make_leaf_button(_("Email"), false, nullptr);
357 btn->signal_clicked().connect([this, btn, go]() {
358 activate_button(btn);
359 go(9);
360 });
361 menu_box->append(*btn);
362 }
363
364 {
365 auto* btn = make_leaf_button(_("DB ClamAV"), false, nullptr);
366 btn->signal_clicked().connect([this, btn, go]() {
367 activate_button(btn);
368 go(11);
369 });
370 menu_box->append(*btn);
371 }
372
373 {
374 auto* btn = make_leaf_button(_("Opzioni"), false, nullptr);
375 btn->signal_clicked().connect([this, btn, go]() {
376 activate_button(btn);
377 go(12);
378 });
379 menu_box->append(*btn);
380 }
381
382 sidebar_box_->append(*menu_box);
383
384 {
385 auto* spacer = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::VERTICAL);
386 spacer->set_vexpand(true);
387 sidebar_box_->append(*spacer);
388
389 auto* sep = Gtk::make_managed<Gtk::Separator>(Gtk::Orientation::HORIZONTAL);
390 sep->get_style_context()->add_class("sidebar-separator");
391 sidebar_box_->append(*sep);
392 }
393
394 mainBox_.append(*sidebar_box_);
395
396 if (!all_leaf_buttons_.empty())
398
400}
Gtk::Button * make_leaf_button(const std::string &label_text, bool indent=false, Gtk::Box *parent_submenu=nullptr)
Gtk::Box * sidebar_box_
Gtk::Button * make_group_button(const std::string &icon_path, const std::string &label_text, Gtk::Box **out_submenu=nullptr)

References _, activate_button(), active_page_, all_leaf_buttons_, SettingsPage::goto_page(), mainBox_, make_group_button(), make_leaf_button(), resource(), settingsPage_, and sidebar_box_.

Referenced by build_ui(), and SettingsWindow().

◆ build_ui()

void SettingsWindow.build_ui ( )
inlineprivate

Definition at line 110 of file SettingsWindow.vala.

110 {
111
112 root_box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
113 root_box.hexpand = true;
114 root_box.vexpand = true;
115 root_box.halign = Gtk.Align.FILL;
116 root_box.valign = Gtk.Align.FILL;
117 set_child(root_box);
118
121
122 root_box.append(sidebar);
123 root_box.append(content_box);
124 }

References build_content(), build_sidebar(), content_box, root_box, and sidebar.

Referenced by SettingsWindow().

◆ clear_nav_selection()

void SettingsWindow.clear_nav_selection ( )
inlineprivate

Definition at line 454 of file SettingsWindow.vala.

454 {
455 foreach (var btn in nav_buttons) {
456 btn.get_style_context().remove_class("active-sidebar-button");
457 }
458 }

References nav_buttons.

Referenced by activate_tab().

◆ connect_signals()

void SettingsWindow.connect_signals ( )
inlineprivate

Definition at line 305 of file SettingsWindow.vala.

305 {
306
307 btn_type.clicked.connect(() => {
308 activate_tab("type", btn_type, _("Type"));
309 });
310
311 btn_location.clicked.connect(() => {
312 activate_tab("location", btn_location, _("Location"));
313 });
314
315 btn_schedule.clicked.connect(() => {
316 activate_tab("schedule", btn_schedule, _("Schedule"));
317 });
318
319 btn_users.clicked.connect(() => {
320 activate_tab("users", btn_users, _("Users"));
321 });
322
323 btn_filters.clicked.connect(() => {
324 activate_tab("filters", btn_filters, _("Filters"));
325 });
326
327 btn_misc.clicked.connect(() => {
328 activate_tab("misc", btn_misc, _("Misc"));
329 });
330
331 btn_close.clicked.connect(() => {
333 else this.destroy();
334 });
335
336 backend_box.type_changed.connect(() => {
337 exclude_box.visible = !App.btrfs_mode;
340
341 if (App.btrfs_mode && stack.get_visible_child_name() == "filters") {
342 activate_tab("type", btn_type, _("Type"));
343 }
344
346 });
347 }
Main App
bool btrfs_mode
Definition Main.vala:52
signal void type_changed()
void refresh()

References _, activate_tab(), App, backend_box, backup_dev_box, btn_close, btn_filters, btn_location, btn_misc, btn_schedule, btn_type, btn_users, Main.btrfs_mode, embedded_mode, BackupDeviceBox.refresh(), UsersBox.refresh(), request_close(), stack, SnapshotBackendBox.type_changed(), update_bottom_navigation(), and users_box.

Referenced by SettingsWindow().

◆ create_nav_button()

Gtk.Button SettingsWindow.create_nav_button ( string icon_name,
string text )
inlineprivate

Definition at line 349 of file SettingsWindow.vala.

349 {
350
351 var btn = new Gtk.Button();
352 btn.hexpand = true;
353 btn.halign = Gtk.Align.FILL;
354 btn.margin_start = 8;
355 btn.margin_end = 8;
356 btn.get_style_context().add_class("sidebar-button");
357
358 var row = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 10);
359 row.margin_top = 8;
360 row.margin_bottom = 8;
361 row.margin_start = 10;
362 row.margin_end = 10;
363
364 var img = themed_icon(icon_name, 18);
365 var lbl = new Gtk.Label(text);
366 lbl.xalign = 0.0f;
367 lbl.hexpand = true;
368
369 row.append(img);
370 row.append(lbl);
371
372 btn.set_child(row);
373
374 nav_buttons.add(btn);
375
376 return btn;
377 }

References nav_buttons, and themed_icon().

Referenced by build_sidebar().

◆ detach_root_widget()

Gtk.Widget SettingsWindow.detach_root_widget ( )
inline

Definition at line 482 of file SettingsWindow.vala.

482 {
483 set_child(null);
484 return root_box;
485 }

References root_box.

Referenced by MainWindow.init_settings_page().

◆ get_current_tab_index()

int SettingsWindow.get_current_tab_index ( )
inlineprivate

Definition at line 391 of file SettingsWindow.vala.

391 {
392 var order = get_tab_order();
393 var current = stack.get_visible_child_name();
394 for (int i = 0; i < order.size; i++) {
395 if (order[i] == current)
396 return i;
397 }
398 return 0;
399 }

References get_tab_order(), and stack.

Referenced by activate_relative_tab(), and update_bottom_navigation().

◆ get_tab_order()

Gee.ArrayList< string > SettingsWindow.get_tab_order ( )
inlineprivate

Definition at line 379 of file SettingsWindow.vala.

379 {
380 var order = new Gee.ArrayList<string>();
381 order.add("type");
382 order.add("location");
383 order.add("schedule");
384 order.add("users");
385 if (!App.btrfs_mode)
386 order.add("filters");
387 order.add("misc");
388 return order;
389 }

References App, and Main.btrfs_mode.

Referenced by activate_relative_tab(), get_current_tab_index(), and update_bottom_navigation().

◆ init_delayed()

bool SettingsWindow.init_delayed ( )
inlineprivate

Definition at line 460 of file SettingsWindow.vala.

460 {
461
462 if (tmr_init > 0) {
463 Source.remove(tmr_init);
464 tmr_init = 0;
465 }
466
468 stack.set_visible_child_name("type");
469 activate_tab("type", btn_type, _("Type"));
470
471 this.set_default_size(def_width, def_height);
472
473 return false;
474 }

References _, activate_tab(), backend_box, btn_type, def_height, def_width, SnapshotBackendBox.refresh(), stack, and tmr_init.

Referenced by SettingsWindow().

◆ make_group_button()

Gtk::Button * SettingsWindow::make_group_button ( const std::string & icon_path,
const std::string & label_text,
Gtk::Box ** out_submenu = nullptr )
private

Definition at line 85 of file SettingsWindow.cpp.

88{
89 auto outer = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::HORIZONTAL, 6);
90
91 auto icon_box = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::VERTICAL);
92 icon_box->set_size_request(16, 16);
93 icon_box->set_halign(Gtk::Align::START);
94 icon_box->set_valign(Gtk::Align::CENTER);
95
96 auto pic = Gtk::make_managed<Gtk::Picture>();
97 if (!icon_path.empty()) {
98 try {
99 auto pb = Gdk::Pixbuf::create_from_file(icon_path);
100 auto scaled = pb->scale_simple(16, 16, Gdk::InterpType::BILINEAR);
101 pic->set_paintable(Gdk::Texture::create_for_pixbuf(scaled));
102 pic->set_content_fit(Gtk::ContentFit::FILL);
103 pic->set_keep_aspect_ratio(true);
104 } catch (...) {}
105 }
106
107 icon_box->append(*pic);
108 outer->append(*icon_box);
109
110 auto lbl = Gtk::make_managed<Gtk::Label>(label_text);
111 lbl->set_halign(Gtk::Align::START);
112 lbl->set_hexpand(true);
113 outer->append(*lbl);
114
115 auto chevron = Gtk::make_managed<Gtk::Label>("▸");
116 chevron->set_halign(Gtk::Align::END);
117 outer->append(*chevron);
118
119 auto btn = Gtk::make_managed<Gtk::Button>();
120 btn->set_child(*outer);
121 btn->get_style_context()->add_class("sidebar-button");
122
123 if (out_submenu) {
124 auto sub = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::VERTICAL, 2);
125 sub->set_visible(false);
126 sub->get_style_context()->add_class("sidebar-submenu");
127 *out_submenu = sub;
128
129 btn->signal_clicked().connect([sub, chevron]() {
130 bool vis = sub->get_visible();
131 sub->set_visible(!vis);
132 chevron->set_text(vis ? "▸" : "▾");
133 });
134 }
135
136 return btn;
137}

Referenced by build_sidebar().

◆ make_leaf_button()

Gtk::Button * SettingsWindow::make_leaf_button ( const std::string & label_text,
bool indent = false,
Gtk::Box * parent_submenu = nullptr )
private

Definition at line 139 of file SettingsWindow.cpp.

142{
143 auto lbl = Gtk::make_managed<Gtk::Label>(label_text);
144 lbl->set_halign(Gtk::Align::START);
145
146 auto btn = Gtk::make_managed<Gtk::Button>();
147 btn->set_child(*lbl);
148 btn->get_style_context()->add_class("sidebar-button");
149 btn->get_style_context()->add_class("sidebar-leaf");
150
151 if (indent)
152 btn->get_style_context()->add_class("sidebar-leaf-indent");
153
154 all_leaf_buttons_.push_back(btn);
155 button_submenu_[btn] = parent_submenu;
156 return btn;
157}

References all_leaf_buttons_, and button_submenu_.

Referenced by build_sidebar().

◆ on_close_request()

bool SettingsWindow.on_close_request ( )
inlineprivate

Definition at line 476 of file SettingsWindow.vala.

476 {
477
478 save_changes();
479 return false;
480 }

References save_changes().

Referenced by SettingsWindow().

◆ reload_themed_icons()

void SettingsWindow.reload_themed_icons ( )
inline

Definition at line 509 of file SettingsWindow.vala.

509 {
510 for (int i = 0; i < themed_img_list.size; i++) {
511 var img = themed_img_list[i];
512 var name = themed_img_name[i];
513 var sz = themed_img_size[i];
514 var pix = IconManager.lookup(name, sz);
515 if (pix != null) {
516 img.set_from_pixbuf(pix);
517 } else {
518 img.set_from_icon_name(name);
519 }
520 }
521 }
Gee.ArrayList< int > themed_img_size
Gee.ArrayList< string > themed_img_name
Gee.ArrayList< Gtk.Image > themed_img_list

References IconManager.lookup(), themed_img_list, themed_img_name, and themed_img_size.

Referenced by MainWindow.reload_themed_icons().

◆ request_close()

signal void SettingsWindow.request_close ( )

◆ save_changes()

void SettingsWindow.save_changes ( )
inlineprivate

Definition at line 487 of file SettingsWindow.vala.

487 {
488
491 }
void save_changes()
void cron_job_update()
Definition Main.vala:4463

References App, Main.cron_job_update(), exclude_box, and ExcludeBox.save_changes().

Referenced by build_content(), and on_close_request().

◆ themed_icon()

Gtk.Image SettingsWindow.themed_icon ( string icon_name,
int size )
inlineprivate

Definition at line 501 of file SettingsWindow.vala.

501 {
502 var img = IconManager.lookup_image(icon_name, size);
503 themed_img_list.add(img);
504 themed_img_name.add(icon_name);
505 themed_img_size.add(size);
506 return img;
507 }

References IconManager.lookup_image(), themed_img_list, themed_img_name, and themed_img_size.

Referenced by build_sidebar(), and create_nav_button().

◆ update_bottom_navigation()

void SettingsWindow.update_bottom_navigation ( )
inlineprivate

Definition at line 433 of file SettingsWindow.vala.

433 {
434 int index = get_current_tab_index();
435 int last = get_tab_order().size - 1;
436 btn_prev.sensitive = index > 0;
437 btn_next.sensitive = index < last;
438 }

References get_current_tab_index(), and get_tab_order().

Referenced by activate_tab(), and connect_signals().

Member Data Documentation

◆ active_button_

Gtk::Button* SettingsWindow::active_button_ = nullptr
private

Definition at line 43 of file SettingsWindow.hpp.

Referenced by activate_button(), and SettingsWindow().

◆ active_page_

int SettingsWindow::active_page_ = 0
private

Definition at line 44 of file SettingsWindow.hpp.

Referenced by build_sidebar(), and SettingsWindow().

◆ all_leaf_buttons_

std::vector<Gtk::Button*> SettingsWindow::all_leaf_buttons_
private

◆ backend_box

SnapshotBackendBox SettingsWindow.backend_box
private

Definition at line 47 of file SettingsWindow.vala.

Referenced by build_pages(), connect_signals(), and init_delayed().

◆ backup_dev_box

BackupDeviceBox SettingsWindow.backup_dev_box
private

Definition at line 48 of file SettingsWindow.vala.

Referenced by build_pages(), and connect_signals().

◆ bottom_bar

Gtk.Box SettingsWindow.bottom_bar
private

Definition at line 43 of file SettingsWindow.vala.

Referenced by build_content().

◆ btn_close

Gtk.Button SettingsWindow.btn_close
private

Definition at line 60 of file SettingsWindow.vala.

Referenced by build_headerbar(), build_sidebar(), and connect_signals().

◆ btn_filters

Gtk.Button SettingsWindow.btn_filters
private

Definition at line 58 of file SettingsWindow.vala.

Referenced by activate_tab_by_name(), build_sidebar(), and connect_signals().

◆ btn_location

Gtk.Button SettingsWindow.btn_location
private

Definition at line 55 of file SettingsWindow.vala.

Referenced by activate_tab_by_name(), build_sidebar(), and connect_signals().

◆ btn_misc

Gtk.Button SettingsWindow.btn_misc
private

Definition at line 59 of file SettingsWindow.vala.

Referenced by activate_tab_by_name(), build_sidebar(), and connect_signals().

◆ btn_next

Gtk.Button SettingsWindow.btn_next
private

Definition at line 62 of file SettingsWindow.vala.

Referenced by build_content().

◆ btn_prev

Gtk.Button SettingsWindow.btn_prev
private

Definition at line 61 of file SettingsWindow.vala.

Referenced by build_content().

◆ btn_schedule

Gtk.Button SettingsWindow.btn_schedule
private

Definition at line 56 of file SettingsWindow.vala.

Referenced by activate_tab_by_name(), build_sidebar(), and connect_signals().

◆ btn_type

Gtk.Button SettingsWindow.btn_type
private

◆ btn_users

Gtk.Button SettingsWindow.btn_users
private

Definition at line 57 of file SettingsWindow.vala.

Referenced by activate_tab_by_name(), build_sidebar(), and connect_signals().

◆ button_submenu_

std::map<Gtk::Button*, Gtk::Box*> SettingsWindow::button_submenu_
private

Definition at line 41 of file SettingsWindow.hpp.

Referenced by activate_button(), and make_leaf_button().

◆ content_body_box

Gtk.Box SettingsWindow.content_body_box
private

Definition at line 42 of file SettingsWindow.vala.

Referenced by build_content().

◆ content_box

Gtk.Box SettingsWindow.content_box
private

Definition at line 40 of file SettingsWindow.vala.

Referenced by build_content(), and build_ui().

◆ content_header_box

Gtk.Box SettingsWindow.content_header_box
private

Definition at line 41 of file SettingsWindow.vala.

Referenced by build_content().

◆ def_height

int SettingsWindow.def_height = 760
private

Definition at line 70 of file SettingsWindow.vala.

Referenced by init_delayed(), and SettingsWindow().

◆ def_width

int SettingsWindow.def_width = 1100
private

Definition at line 69 of file SettingsWindow.vala.

Referenced by init_delayed(), and SettingsWindow().

◆ embedded_mode

bool SettingsWindow.embedded_mode = false
private

Definition at line 71 of file SettingsWindow.vala.

Referenced by build_content(), connect_signals(), and SettingsWindow().

◆ exclude_box

ExcludeBox SettingsWindow.exclude_box
private

Definition at line 50 of file SettingsWindow.vala.

Referenced by build_pages(), and save_changes().

◆ lbl_page_title

Gtk.Label SettingsWindow.lbl_page_title
private

Definition at line 64 of file SettingsWindow.vala.

Referenced by build_content().

◆ mainBox_

Gtk::Box SettingsWindow::mainBox_ {Gtk::Orientation::HORIZONTAL, 0}
private

Definition at line 34 of file SettingsWindow.hpp.

Referenced by build_sidebar(), and SettingsWindow().

◆ misc_box

MiscBox SettingsWindow.misc_box
private

Definition at line 52 of file SettingsWindow.vala.

Referenced by build_pages().

◆ nav_buttons

Gee.ArrayList<Gtk.Button> SettingsWindow.nav_buttons
private

Definition at line 66 of file SettingsWindow.vala.

Referenced by clear_nav_selection(), create_nav_button(), and SettingsWindow().

◆ root_box

Gtk.Box SettingsWindow.root_box
private

Definition at line 38 of file SettingsWindow.vala.

Referenced by build_ui(), and detach_root_widget().

◆ schedule_box

ScheduleBox SettingsWindow.schedule_box
private

Definition at line 49 of file SettingsWindow.vala.

Referenced by build_pages().

◆ settingsPage_

SettingsPage* SettingsWindow::settingsPage_ = nullptr
private

Definition at line 37 of file SettingsWindow.hpp.

Referenced by build_sidebar(), and SettingsWindow().

◆ sidebar

Gtk.Box SettingsWindow.sidebar
private

Definition at line 39 of file SettingsWindow.vala.

Referenced by build_sidebar(), and build_ui().

◆ sidebar_box_

Gtk::Box* SettingsWindow::sidebar_box_ = nullptr
private

Definition at line 38 of file SettingsWindow.hpp.

Referenced by build_sidebar().

◆ stack

Gtk.Stack SettingsWindow.stack
private

◆ stack_

Gtk::Stack SettingsWindow::stack_
private

Definition at line 35 of file SettingsWindow.hpp.

Referenced by SettingsWindow().

◆ themed_img_list

Gee.ArrayList<Gtk.Image> SettingsWindow.themed_img_list = new Gee.ArrayList<Gtk.Image>()
private

Definition at line 74 of file SettingsWindow.vala.

Referenced by reload_themed_icons(), and themed_icon().

◆ themed_img_name

Gee.ArrayList<string> SettingsWindow.themed_img_name = new Gee.ArrayList<string>()
private

Definition at line 75 of file SettingsWindow.vala.

Referenced by reload_themed_icons(), and themed_icon().

◆ themed_img_size

Gee.ArrayList<int> SettingsWindow.themed_img_size = new Gee.ArrayList<int>()
private

Definition at line 76 of file SettingsWindow.vala.

Referenced by reload_themed_icons(), and themed_icon().

◆ tmr_init

uint SettingsWindow.tmr_init
private

Definition at line 68 of file SettingsWindow.vala.

Referenced by init_delayed(), and SettingsWindow().

◆ users_box

UsersBox SettingsWindow.users_box
private

Definition at line 51 of file SettingsWindow.vala.

Referenced by build_pages(), and connect_signals().


The documentation for this class was generated from the following files: