1
# vim: set ts=4 sw=4 et:
4
# Copyright (C) 2005 Vincent Untz <vuntz@gnome.org>
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.
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.
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 St, Fifth Floor, Boston, MA 02110-1301, USA
27
from sets import Set as set
29
from sabayon import errors
30
from sabayon import debuglog
32
import simpleeditabletreeview
34
# Note that the idea is to only have one toggle to set/unset mandatory settings
35
# for this key and the disable_unsafe_protocols key.
37
class PessulusSafeProtocols:
38
def __init__ (self, lockdownbutton, treeview, addbutton, editbutton, removebutton):
40
self.key = "/apps/epiphany/lockdown/additional_safe_protocols"
41
self.safe_protocols = None
44
self.lockdownbutton = lockdownbutton
45
self.lockdownbutton.connect ("toggled",
46
self.__on_lockdownbutton_toggled)
48
treeview.connect ("destroy", self.__on_destroyed)
49
self.simpleeditabletreeview = simpleeditabletreeview.PessulusSimpleEditableTreeview (treeview, addbutton, editbutton, removebutton)
50
self.simpleeditabletreeview.connect ("changed",
51
self.__on_treeview_changed)
53
(list, mandatory) = globalvar.applier.get_list (self.key,
55
self.safe_protocols = set (list)
56
self.__update_simpleeditabletreeview ()
57
self.lockdownbutton.set (mandatory)
58
self.notify_id = globalvar.applier.notify_add (self.key,
61
def set_sensitive (self, sensitive):
62
self.sensitive = sensitive
63
self.__update_sensitivity ()
65
@errors.checked_callback (debuglog.DEBUG_LOG_DOMAIN_PESSULUS)
66
def __on_notified (self, data):
67
(list, mandatory) = globalvar.applier.get_list (self.key,
69
gconf_set = set (list)
70
if gconf_set != self.safe_protocols:
71
self.safe_protocols = gconf_set
72
self.__update_simpleeditabletreeview ()
73
if mandatory != self.lockdownbutton.get ():
74
self.lockdownbutton.set (mandatory)
76
@errors.checked_callback (debuglog.DEBUG_LOG_DOMAIN_USER)
77
def __on_lockdownbutton_toggled (self, lockdownbutton, mandatory):
78
globalvar.applier.set_list (self.key, gconf.VALUE_STRING,
79
list (self.safe_protocols),
82
@errors.checked_callback (debuglog.DEBUG_LOG_DOMAIN_USER)
83
def __on_treeview_changed (self, simpleeditabletreeview, new_set):
84
if new_set != self.safe_protocols:
85
self.safe_protocols = new_set.copy ()
86
globalvar.applier.set_list (self.key, gconf.VALUE_STRING,
87
list (self.safe_protocols),
88
self.lockdownbutton.get ())
90
def __update_sensitivity (self):
92
sensitive = self.sensitive and globalvar.applier.key_is_writable (self.key)
94
sensitive = self.sensitive
96
self.simpleeditabletreeview.set_sensitive (sensitive)
98
def __update_simpleeditabletreeview (self):
99
self.__update_sensitivity ()
100
self.simpleeditabletreeview.update_set (self.safe_protocols)
102
@errors.checked_callback (debuglog.DEBUG_LOG_DOMAIN_PESSULUS)
103
def __on_destroyed (self, treeview):
105
if globalvar.applier:
106
globalvar.applier.notify_remove (self.notify_id)
107
self.notify_id = None