1
# dialog_settings.py.in - edit some settings
3
# Copyright (c) 2005 Canonical
5
# Author: Michael Vogt <mvo@debian.org>
7
# This program is free software; you can redistribute it and/or
8
# modify it under the terms of the GNU General Public License as
9
# published by the Free Software Foundation; either version 2 of the
10
# License, or (at your option) any later version.
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
17
# You should have received a copy of the GNU General Public License
18
# along with this program; if not, write to the Free Software
19
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
27
periodicAptConfFile = "/etc/apt/apt.conf.d/10periodic"
28
archiveAptConfFile = "/etc/apt/apt.conf.d/20archive"
30
class dialog_settings:
31
def save_periodic_config(self):
35
for key in self.conf_map:
36
cb = self.gladexml.get_widget("checkbutton_%s"% key)
37
sb = self.gladexml.get_widget("spinbutton_%s"% key)
38
if cb and not cb.get_active():
39
#print "%s=%s" % (self.conf_map[key], "0")
40
apt_pkg.Config.Set(self.conf_map[key], "0")
42
value = sb.get_value()
43
apt_pkg.Config.Set(self.conf_map[key], str(value))
44
#print "%s=%s" % (self.conf_map[key], value)
46
# special case for autodownload, it has the same interval as
47
# Update-Package-Lists
48
cb = self.gladexml.get_widget("checkbutton_autodownload")
51
autoupdate = str(apt_pkg.Config.FindI("APT::Periodic::Update-Package-Lists"))
52
apt_pkg.Config.Set(self.conf_map[key], autoupdate)
54
apt_pkg.Config.Set(self.conf_map[key], "0")
57
# write both config-prefixes to different files
58
for (file, prefix) in ((periodicAptConfFile, "APT::Periodic"),
59
(archiveAptConfFile, "APT::Archives")):
62
if os.path.isfile(file):
63
content=open(file,"r").readlines()
65
cnf = apt_pkg.Config.SubTree(prefix)
69
# don't write the udpated keys
71
for key in cnf.List():
72
#print "%s=%s" % (key, cnf[key])
73
if line.find("%s::%s" % (prefix,key)) >= 0:
80
f.write("%s::%s \"%s\";\n" % (prefix,i,cnf.FindI((i))))
83
def toggle_show_disabled(self, widget, data):
84
self.show_disabled = widget.get_active()
85
self.gconfclient.set_bool("/apps/gnome-software-properties/show_disabled",\
88
def toggle_settings_cb(self, widget, data):
89
mode = widget.get_active()
90
self.gladexml.get_widget(data).set_sensitive(mode)
93
res = self.main_window.run()
94
self.save_periodic_config()
95
self.main_window.hide()
98
def __init__(self, parent, glade):
100
self.gladexml = glade
101
self.main_window = self.gladexml.get_widget("dialog_settings")
102
self.main_window.set_transient_for(parent)
104
self.gconfclient = gconf.client_get_default()
106
# preferences entries
107
self.show_disabled = self.gconfclient.get_bool("/apps/gnome-software-properties/show_disabled")
109
checkbutton_show_disabled = self.gladexml.get_widget("checkbutton_show_disabled")
110
checkbutton_show_disabled.set_active(self.show_disabled)
111
checkbutton_show_disabled.connect("toggled", self.toggle_show_disabled, None)
116
# set the update stuff
118
"autoupdate" : "APT::Periodic::Update-Package-Lists",
119
"autodownload" : "APT::Periodic::Download-Upgradeable-Packages",
120
"autoclean" : "APT::Periodic::AutocleanInterval",
121
"max_size" : "APT::Archives::MaxSize",
122
"max_age" : "APT::Archives::MaxAge"
125
for key in self.conf_map:
126
value = apt_pkg.Config.FindI(self.conf_map[key])
127
#print "%s=%s" % (key, value)
128
cb = self.gladexml.get_widget("checkbutton_%s"% key)
130
# print "checkbutton_%s not found" % key
131
sb = self.gladexml.get_widget("spinbutton_%s"% key)
133
#print "setting %s to %s" % (key, value)
136
# print "spinbutton_%s not found" % key
137
box = self.gladexml.get_widget("vbox_%s"% key)
139
# print "vbox_%s not found" % key
141
cb.connect("toggled", self.toggle_settings_cb, ("vbox_%s" % key))