~ubuntu-branches/ubuntu/precise/activity-log-manager/precise

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*
 * activity-log-manager.vala
 * Copyright (C) Seif Lotfy 2012 <seif@lotfy.com>
 * Copyright (C) Stefano Candori 2012 <stefano.candori@gmail.com>
 * Copyright (C) Manish Sinha 2012 <manishsinha@ubuntu.com>
 * 
 * alm is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 * 
 * alm is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.";
 */
namespace Alm {
	public class ActivityLogManager : Gtk.Box {
		private Gtk.Notebook notebook;
		private HistoryWidget history_widget;
		private FilesWidget files_widget;
		private ApplicationsWidget apps_widget;

		private Blacklist blacklist;
		private Gtk.Switch logging_switch;

		public ActivityLogManager () {
			Object(orientation: Gtk.Orientation.VERTICAL);
			this.set_size_request(600, 450);
			this.spacing = 6;

			this.margin = 12;

			blacklist = new Blacklist();
			notebook = new Gtk.Notebook();

			this.pack_start(notebook, true, true, 0);

			history_widget = new HistoryWidget();
			var history_label = new Gtk.Label("History");
			history_label.width_chars = 11;
			notebook.append_page(history_widget, history_label);

			files_widget = new FilesWidget(blacklist);
			var files_label = new Gtk.Label("Files");
			files_label.width_chars = 11;
			notebook.append_page(files_widget, files_label);

			apps_widget = new ApplicationsWidget(blacklist);
			var app_label = new Gtk.Label("Applications");
			app_label.width_chars = 12;
			notebook.append_page(apps_widget, app_label);

			var logging_box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 6);
			logging_box.margin_right = 12;

			var logging_label = new Gtk.Label(null);
			logging_label.set_markup("<b>Record Activity</b>");

			logging_switch = new Gtk.Switch();
			logging_box.pack_end(logging_switch, false, false);
			logging_box.pack_end(logging_label, false, false);
			logging_switch.set_active(!blacklist.get_incognito());
			blacklist.incognito_toggled.connect(on_incognito_toggled);

			logging_switch.notify["active"].connect(on_switch_activated);

			this.pack_start(logging_box, false, false, 9);
		
			this.show_all();
		}

		public void on_incognito_toggled(bool status) {
			this.logging_switch.set_active(!status);
		}
		
		public void on_switch_activated() {
			var recording = !blacklist.get_incognito();
			if (this.logging_switch.get_active() != recording) {
				blacklist.set_incognito(recording);
			}
		}
	}
}