summaryrefslogtreecommitdiff
path: root/SoftwareProperties
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2006-02-23 15:15:03 +0100
committerMichael Vogt <michael.vogt@ubuntu.com>2006-02-23 15:15:03 +0100
commitafb9453a7bdb99719ea6c4292a028d7ff7cccc26 (patch)
tree097bb8ec9de4649e0da2a2885a08043ea3c5e224 /SoftwareProperties
parent0e06105183cd1757ce4369bc778ece8363330fbf (diff)
parent28d131b543b638589c243abb6b1c247c8c653321 (diff)
downloadpython-apt-afb9453a7bdb99719ea6c4292a028d7ff7cccc26.tar.gz
* merged with sebi
Diffstat (limited to 'SoftwareProperties')
-rw-r--r--SoftwareProperties/SoftwareProperties.py107
-rw-r--r--SoftwareProperties/aptsources.py32
-rw-r--r--SoftwareProperties/dialog_add.py89
3 files changed, 167 insertions, 61 deletions
diff --git a/SoftwareProperties/SoftwareProperties.py b/SoftwareProperties/SoftwareProperties.py
index 690b30dd..0e9a0f0d 100644
--- a/SoftwareProperties/SoftwareProperties.py
+++ b/SoftwareProperties/SoftwareProperties.py
@@ -37,6 +37,7 @@ from UpdateManager.Common.SimpleGladeApp import SimpleGladeApp
import aptsources
import dialog_add
import dialog_edit
+import dialog_sources_list
from dialog_apt_key import apt_key
from utils import *
@@ -50,11 +51,22 @@ CONF_MAP = {
"max_size" : "APT::Archives::MaxSize",
"max_age" : "APT::Archives::MaxAge"
}
-
+(
+ COLUMN_ACTIVE,
+ COLUMN_DESC
+) = range(2)
class SoftwareProperties(SimpleGladeApp):
- def __init__(self, datadir=None, options=None, parent=None):
+ def __init__(self, datadir=None, options=None, file=None, parent=None):
+
+ # set a default window icon
+ icons = gtk.icon_theme_get_default()
+ try:
+ logo=icons.load_icon("update-manager", 48, 0)
+ gtk.window_set_default_icon_list(logo)
+ except:
+ pass
# FIXME: some saner way is needed here
if datadir == None:
@@ -64,6 +76,8 @@ class SoftwareProperties(SimpleGladeApp):
None, domain="update-manager")
self.modified = False
+ self.file = file
+
#self.gnome_program = gnome.init("Software Properties", "0.41")
#self.gconfclient = gconf.client_get_default()
@@ -170,25 +184,72 @@ class SoftwareProperties(SimpleGladeApp):
self.init_keyslist()
self.reload_keyslist()
+ # drag and drop support for sources.list
+ self.treeview_sources.drag_dest_set(gtk.DEST_DEFAULT_ALL, \
+ [('text/uri-list',0, 0)], \
+ gtk.gdk.ACTION_COPY)
+ self.treeview_sources.connect("drag_data_received",\
+ self.on_sources_drag_data_received)
+
+
+ # call the add sources.list dialog if we got a file from the cli
+ if self.file != None:
+ self.open_file(file)
+
+ def open_file(self, file):
+ """Show an confirmation for adding the channels of the specified file"""
+ dialog = dialog_sources_list.AddSourcesList(self.window_main,
+ self.sourceslist,
+ self.datadir,
+ file)
+ res = dialog.run()
+ if res == gtk.RESPONSE_OK:
+ self.reload_sourceslist()
+ self.modified = True
+
+ def on_sources_drag_data_received(self, widget, context, x, y,
+ selection, target_type, timestamp):
+ """Extract the dropped file pathes and open the first file, only"""
+ uri = selection.data.strip()
+ uri_splitted = uri.split()
+ if len(uri_splitted)>0:
+ self.open_file(uri_splitted[0])
+
def hide(self):
self.window_main.hide()
def init_sourceslist(self):
- self.source_store = gtk.ListStore(str, bool, gobject.TYPE_PYOBJECT)
+ self.source_store = gtk.ListStore(gobject.TYPE_BOOLEAN,
+ gobject.TYPE_STRING,
+ gobject.TYPE_PYOBJECT)
self.treeview_sources.set_model(self.source_store)
- tr = gtk.CellRendererText()
- tr.set_property("xpad", 10)
- tr.set_property("ypad", 10)
-
- source_col = gtk.TreeViewColumn("Description", tr, markup=LIST_MARKUP)
- source_col.set_max_width(500)
-
- self.treeview_sources.append_column(source_col)
+ cell_desc = gtk.CellRendererText()
+ #cell_desc.set_property("xpad", 10)
+ #cell_desc.set_property("ypad", 10)
+ col_desc = gtk.TreeViewColumn(_("Software Channel"), cell_desc,
+ markup=COLUMN_DESC)
+ col_desc.set_max_width(500)
+
+ cell_toggle = gtk.CellRendererToggle()
+ cell_toggle.connect('toggled', self.on_channel_toggled)
+ col_active = gtk.TreeViewColumn(_("Active"), cell_toggle,
+ active=COLUMN_ACTIVE)
+
+ self.treeview_sources.append_column(col_active)
+ self.treeview_sources.append_column(col_desc)
self.sourceslist = aptsources.SourcesList()
self.matcher = aptsources.SourceEntryMatcher()
+ def on_channel_toggled(self, cell_toggle, path):
+ """Enable or disable the selected channel"""
+ iter = self.source_store.get_iter((int(path),))
+ source_entry = self.source_store.get_value(iter, LIST_ENTRY_OBJ)
+ source_entry.disabled = not source_entry.disabled
+ self.reload_sourceslist()
+ self.modified = True
+
def init_keyslist(self):
self.keys_store = gtk.ListStore(str)
self.treeview2.set_model(self.keys_store)
@@ -201,16 +262,14 @@ class SoftwareProperties(SimpleGladeApp):
def reload_sourceslist(self):
self.source_store.clear()
for source in self.sourceslist.list:
- if source.invalid or source.disabled:
+ if source.invalid:
continue
- (a_type, dist, comps) = self.matcher.match(source)
-
- contents = ""
- if source.comment != "":
- contents += "<i>%s</i>\n\n" % (source.comment)
- contents +="<big><b>%s </b></big> (%s) <small>\n%s</small>" % (dist,a_type, comps)
+ (nice_type, nice_dist, nice_comps) = self.matcher.match(source)
- self.source_store.append([contents, not source.disabled, source])
+ contents = "<b>%s</b>%s" % (nice_dist, nice_comps)
+ if source.type == "deb-src":
+ contents = "<b>%s</b> - %s %s" % (nice_dist, nice_type, nice_comps)
+ self.source_store.append([not source.disabled, contents, source])
def reload_keyslist(self):
self.keys_store.clear()
@@ -220,11 +279,11 @@ class SoftwareProperties(SimpleGladeApp):
def on_combobox_update_interval_changed(self, widget):
i = self.combobox_update_interval.get_active()
if i != -1:
- value = self.combobox_interval_mapping[i]
- # Only write the key if it has changed
- if not value == apt_pkg.Config.FindI(CONF_MAP["autoupdate"]):
- apt_pkg.Config.Set(CONF_MAP["autoupdate"], str(value))
- self.write_config()
+ value = self.combobox_interval_mapping[i]
+ # Only write the key if it has changed
+ if not value == apt_pkg.Config.FindI(CONF_MAP["autoupdate"]):
+ apt_pkg.Config.Set(CONF_MAP["autoupdate"], str(value))
+ self.write_config()
def on_opt_autoupdate_toggled(self, widget):
if self.checkbutton_auto_update.get_active():
diff --git a/SoftwareProperties/aptsources.py b/SoftwareProperties/aptsources.py
index 03459adf..f751cf7c 100644
--- a/SoftwareProperties/aptsources.py
+++ b/SoftwareProperties/aptsources.py
@@ -102,8 +102,16 @@ class SourceEntry:
line = line[:i]
# source is ok, split it and see what we have
pieces = self.mysplit(line)
+ # Sanity check
+ if len(pieces) < 3:
+ self.invalid = True
+ return
# Type, deb or deb-src
self.type = string.strip(pieces[0])
+ # Sanity check
+ if self.type not in ("deb", "deb-src"):
+ self.invalid = True
+ return
# URI
self.uri = string.strip(pieces[1])
# distro and components (optional)
@@ -326,7 +334,7 @@ class SourceEntryMatcher:
_ = gettext.gettext
self.type_list = []
self.type_list.append(self.MatchType("^deb$",_("Binary")))
- self.type_list.append(self.MatchType("^deb-src$",_("Source")))
+ self.type_list.append(self.MatchType("^deb-src$",_("Source Code")))
self.dist_list = []
@@ -338,7 +346,7 @@ class SourceEntryMatcher:
# CDs
self.dist_list.append(self.MatchDist("cdrom:\[Ubuntu.*5.10",
".*",
- _("CD disk with Ubuntu 5.10 \"Breezy Badger\""),
+ _("CD disk with Ubuntu 5.10 'Breezy Badger'"),
ubuntu_comps, ubuntu_comps_descr))
self.dist_list.append(self.MatchDist("cdrom:\[Ubuntu.*5.04",
".*",
@@ -352,7 +360,7 @@ class SourceEntryMatcher:
# Warty
self.dist_list.append(self.MatchDist(".*archive.ubuntu.com/ubuntu",
"^warty$",
- "Ubuntu 4.10 \"Warty Warthog\"",
+ "Ubuntu 4.10 'Warty Warthog'",
ubuntu_comps, ubuntu_comps_descr))
self.dist_list.append(self.MatchDist(".*security.ubuntu.com/ubuntu",
"^warty-security$",
@@ -377,7 +385,7 @@ class SourceEntryMatcher:
ubuntu_comps, ubuntu_comps_descr))
self.dist_list.append(self.MatchDist(".*archive.ubuntu.com/ubuntu",
"^hoary$",
- "Ubuntu 5.04 \"Hoary Hedgehog\"",
+ "Ubuntu 5.04 'Hoary Hedgehog'",
ubuntu_comps, ubuntu_comps_descr))
self.dist_list.append(self.MatchDist(".*archive.ubuntu.com/ubuntu",
"^hoary-updates$",
@@ -394,7 +402,7 @@ class SourceEntryMatcher:
ubuntu_comps, ubuntu_comps_descr))
self.dist_list.append(self.MatchDist(".*archive.ubuntu.com/ubuntu",
"^breezy$",
- "Ubuntu 5.10 \"Breezy Badger\"",
+ "Ubuntu 5.10 'Breezy Badger'",
ubuntu_comps, ubuntu_comps_descr))
self.dist_list.append(self.MatchDist(".*archive.ubuntu.com/ubuntu",
"^breezy-updates$",
@@ -411,7 +419,7 @@ class SourceEntryMatcher:
ubuntu_comps, ubuntu_comps_descr))
self.dist_list.append(self.MatchDist(".*archive.ubuntu.com/ubuntu",
"^dapper$",
- "Ubuntu 6.04 \"Dapper Drake\"",
+ "Ubuntu 6.04 'Dapper Drake'",
ubuntu_comps, ubuntu_comps_descr))
self.dist_list.append(self.MatchDist(".*archive.ubuntu.com/ubuntu",
"^dapper-updates$",
@@ -430,11 +438,11 @@ class SourceEntryMatcher:
# dists by name
self.dist_list.append(self.MatchDist(".*debian.org/debian",
"^sarge$",
- _("Debian 3.1 \"Sarge\""),
+ _("Debian 3.1 'Sarge'"),
debian_comps, debian_comps_descr))
self.dist_list.append(self.MatchDist(".*debian.org/debian",
"^woody$",
- _("Debian 3.0 \"Woody\""),
+ _("Debian 3.0 'Woody'"),
debian_comps, debian_comps_descr))
# securtiy
self.dist_list.append(self.MatchDist(".*security.debian.org",
@@ -452,7 +460,7 @@ class SourceEntryMatcher:
debian_comps, debian_comps_descr))
self.dist_list.append(self.MatchDist(".*debian.org/debian",
"^unstable$",
- _("Debian Unstable \"Sid\""),
+ _("Debian Unstable 'Sid'"),
debian_comps, debian_comps_descr))
# non-us
@@ -477,6 +485,10 @@ class SourceEntryMatcher:
# some sane defaults first
type_description = source.type
dist_description = source.uri + " " + source.dist
+ # if there is a comment use it instead of the url
+ if source.comment:
+ dist_description = source.comment
+
comp_description = ""
for c in source.comps:
comp_description = comp_description + " " + c
@@ -488,7 +500,7 @@ class SourceEntryMatcher:
for d in self.dist_list:
#print "'%s'" %source.uri
- if re.match(d.uri, source.uri) and re.match(d.dist,source.dist):
+ if re.match(d.uri, source.uri) and re.match(d.dist, source.dist):
dist_description = d.description
comp_description = ""
for c in source.comps:
diff --git a/SoftwareProperties/dialog_add.py b/SoftwareProperties/dialog_add.py
index 9b384623..effd9f24 100644
--- a/SoftwareProperties/dialog_add.py
+++ b/SoftwareProperties/dialog_add.py
@@ -45,16 +45,58 @@ class dialog_add:
self.main = widget = self.gladexml.get_widget("dialog_add")
self.main.set_transient_for(self.parent)
- combo = self.gladexml.get_widget("combobox_what")
+ # Setup the official channel widgets
+ self.combo = self.gladexml.get_widget("combobox_what")
self.gladexml.signal_connect("on_combobox_what_changed", self.on_combobox_what_changed, None)
- # combox box needs
cell = gtk.CellRendererText()
- combo.pack_start(cell, True)
- combo.add_attribute(cell, 'text', 0)
- self.fill_combo(combo)
- self.gladexml.signal_connect("on_button_custom_clicked",
- self.on_button_custom_clicked, None)
+ self.combo.pack_start(cell, True)
+ self.combo.add_attribute(cell, 'text', 0)
+ self.fill_combo(self.combo)
+ # Setup the custom channel widgets
+ self.entry = self.gladexml.get_widget("entry_source_line")
+ self.gladexml.signal_connect("on_entry_source_line_changed",
+ self.check_line)
+
+ # Setup the toggle action
+ self.radio_official = self.gladexml.get_widget("radiobutton_official")
+ self.radio_custom = self.gladexml.get_widget("radiobutton_custom")
+ self.button_add = self.gladexml.get_widget("button_add_channel")
+ self.gladexml.signal_connect("on_radiobutton_custom_toggled",
+ self.on_radio_custom_toggled)
+ self.gladexml.signal_connect("on_radiobutton_official_toggled",
+ self.on_radio_official_toggled)
+
+ # We start with the official channels:
+ self.official = True
+ self.radio_custom.toggled()
+
+ def check_line(self, *args):
+ """Check for a valid apt line"""
+ if self.official == True:
+ self.button_add.set_sensitive(True)
+ return
+
+ line = self.entry.get_text() + "\n"
+ source_entry = aptsources.SourceEntry(line)
+ if source_entry.invalid == True or source_entry.disabled == True:
+ self.button_add.set_sensitive(False)
+ else:
+ self.button_add.set_sensitive(True)
+
+
+ def on_radio_custom_toggled(self, radio):
+ state = radio.get_active()
+ self.entry.set_sensitive(state)
+ self.check_line()
+
+ def on_radio_official_toggled(self, radio):
+ state = radio.get_active()
+ self.combo.set_sensitive(state)
+ for check in self.comps:
+ check.set_sensitive(state)
+ self.official = state
+ self.button_add.set_sensitive(state)
def fill_combo(self,combo):
liststore = gtk.ListStore(gobject.TYPE_STRING,gobject.TYPE_PYOBJECT)
@@ -72,25 +114,14 @@ class dialog_add:
(name, template) = liststore.get(a_iter, 0,1)
self.selected = template
comps = template.comps
+ self.comps=[]
for c in comps:
checkbox = gtk.CheckButton(c.description)
checkbox.set_active(c.on_by_default)
checkbox.set_data("name",c.name)
vbox.pack_start(checkbox)
checkbox.show()
-
- def on_button_custom_clicked(self, widget, data):
- #print "on_button_custom_clicked()"
- # this hide here is ugly :/
- self.main.hide()
- dialog = self.gladexml.get_widget("dialog_add_custom")
- dialog.set_transient_for(self.parent)
- res = dialog.run()
- dialog.hide()
- entry = self.gladexml.get_widget("entry_source_line")
- line = entry.get_text() + "\n"
- self.sourceslist.list.append(aptsources.SourceEntry(line))
- self.main.response(res)
+ self.comps.append(checkbox)
def get_enabled_comps(self, checkbutton):
if checkbutton.get_active():
@@ -100,12 +131,16 @@ class dialog_add:
res = self.main.run()
if res == gtk.RESPONSE_OK:
# add repository
- self.selected_comps = []
- vbox = self.gladexml.get_widget("vbox_comps")
- vbox.foreach(self.get_enabled_comps)
- self.sourceslist.add(self.selected.type,
- self.selected.uri,
- self.selected.dist,
- self.selected_comps)
+ if self.official == True:
+ self.selected_comps = []
+ vbox = self.gladexml.get_widget("vbox_comps")
+ vbox.foreach(self.get_enabled_comps)
+ self.sourceslist.add(self.selected.type,
+ self.selected.uri,
+ self.selected.dist,
+ self.selected_comps)
+ else:
+ line = self.entry.get_text() + "\n"
+ self.sourceslist.list.append(aptsources.SourceEntry(line))
self.main.hide()
return res