Skip to content
API Documentation
BastionGuard™
RestoreExcludeBox.vala
Go to the documentation of this file.
1/*
2 * RestoreExcludeBox.vala
3 *
4 * Copyright 2012-2018 Tony George <teejeetech@gmail.com>
5 *
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.
10 *
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.
15 *
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,
19 * MA 02110-1301, USA.
20 *
21 *
22 */
23
24using Gtk;
25using Gee;
26
27using TeeJee.Logging;
32using TeeJee.System;
33using TeeJee.Misc;
34
35class RestoreExcludeBox : Gtk.Box{
36
37 //private Gtk.CheckButton chk_web;
38 private Gtk.CheckButton chk_other;
39 private Gtk.CheckButton chk_web;
40 private Gtk.CheckButton chk_torrent;
41
42 private Gtk.Window parent_window;
43
44 public RestoreExcludeBox (Gtk.Window _parent_window) {
45
46 log_debug("RestoreExcludeBox: RestoreExcludeBox()");
47
48 //base(Gtk.Orientation.VERTICAL, 6); // issue with vala
49 GLib.Object(orientation: Gtk.Orientation.VERTICAL, spacing: 6); // work-around
50 parent_window = _parent_window;
51 margin_top = 12;
52 margin_bottom = 12;
53 margin_start = 12;
54 margin_end = 12;
55
56 // app settings header --------------------------------
57
58 var label = add_label_header(this, _("Exclude Application Settings"), true);
59
60 add_label(this, _("Select applications to exclude from restore"));
61
62 // web browsers --------------------------------
63
64 var chk = add_checkbox(this, _("Web Browsers") + " (%s)".printf(_("Recommended")));
65 chk.active = true;
66 chk.margin_top = 12;
67 chk.margin_bottom = 0;
68 chk_web = chk;
69
70 chk.toggled.connect(()=>{
71 foreach(var name in new string[]{
72 "chromium", "google-chrome", "mozilla", "midori", "epiphany",
73 "opera", "opera-stable", "opera-beta", "opera-developer" }){
74 if (AppExcludeEntry.app_map.has_key(name)){
75 AppExcludeEntry.app_map[name].enabled = chk_web.active;
76 }
77 }
78 });
79
80 label = add_label(
81 this, _("Firefox, Chromium, Chrome, Opera, Epiphany, Midori"), false, true);
82 label.margin_top = 0;
83 label.margin_bottom = 6;
84 label.margin_start = 24;
85 label.wrap = true;
86 label.wrap_mode = Pango.WrapMode.WORD_CHAR;
87
88 var tt = _("Keep configuration files for web browsers like Firefox and Chrome. If un-checked, previous configuration files will be restored from snapshot");
89 chk.set_tooltip_text(tt);
90 label.set_tooltip_text(tt);
91
92 // torrent clients ----------------------------
93
94 chk = add_checkbox(this, _("Bittorrent Clients") + " (%s)".printf(_("Recommended")));
95 chk.active = true;
96 chk.margin_bottom = 0;
97 chk_torrent = chk;
98
99 chk.toggled.connect(()=>{
100 foreach(var name in new string[]{
101 "deluge", "transmission" }){
102 if (AppExcludeEntry.app_map.has_key(name)){
103 AppExcludeEntry.app_map[name].enabled = chk_torrent.active;
104 }
105 }
106 });
107
108 label = add_label(this, _("Deluge, Transmission"), false, true);
109 label.margin_top = 0;
110 label.margin_bottom = 6;
111 label.margin_start = 24;
112 label.wrap = true;
113 label.wrap_mode = Pango.WrapMode.WORD_CHAR;
114
115 tt = _("Keep configuration files for bittorrent clients like Deluge, Transmission, etc. If un-checked, previous configuration files will be restored from snapshot.");
116 chk.set_tooltip_text(tt);
117 label.set_tooltip_text(tt);
118
119 // all apps ----------------------------
120
121 chk = add_checkbox(this, _("Other applications (next page)"));
122 chk_other = chk;
123
124 tt = _("Show more applications to exclude on the next page");
125 chk.set_tooltip_text(tt);
126
127 // TODO: medium: add more exclude options
128
129 log_debug("RestoreExcludeBox: RestoreExcludeBox(): exit");
130 }
131
132 public void refresh(){
133
134 chk_web.toggled();
135 chk_torrent.toggled();
136 }
137}
#define _(s)
static Gee.HashMap< string, AppExcludeEntry > app_map
RestoreExcludeBox(Gtk.Window _parent_window)
Gtk.CheckButton chk_web
Gtk.CheckButton chk_torrent
Gtk.CheckButton chk_other
Gtk.Label add_label(Gtk.Box box, string text, bool bold=false, bool italic=false, bool large=false)
void log_debug(string message)