summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--SoftwareProperties/SoftwareProperties.py16
-rw-r--r--SoftwareProperties/dialog_add_sources_list.py52
-rw-r--r--data/glade/SoftwarePropertiesDialogs.glade34
3 files changed, 47 insertions, 55 deletions
diff --git a/SoftwareProperties/SoftwareProperties.py b/SoftwareProperties/SoftwareProperties.py
index 73544205..f7a40821 100644
--- a/SoftwareProperties/SoftwareProperties.py
+++ b/SoftwareProperties/SoftwareProperties.py
@@ -62,6 +62,8 @@ CONF_MAP = {
COLUMN_DESC
) = range(2)
+RESPONSE_REPLACE = 1
+RESPONSE_ADD = 2
# columns of the source_store
(
@@ -446,9 +448,17 @@ class SoftwareProperties(SimpleGladeApp):
self.get_comparable,
self.datadir,
file)
- res = dialog.run()
- if res == gtk.RESPONSE_OK:
- self.modified_sourceslist()
+ (res, new_sources) = dialog.run()
+ if res == RESPONSE_REPLACE:
+ self.sourceslist.list = []
+ if res in (RESPONSE_ADD, RESPONSE_REPLACE):
+ for source in new_sources:
+ self.sourceslist.add(source.type,
+ source.uri,
+ source.dist,
+ source.comps,
+ source.comment)
+ self.modified_sourceslist()
def on_sources_drag_data_received(self, widget, context, x, y,
selection, target_type, timestamp):
diff --git a/SoftwareProperties/dialog_add_sources_list.py b/SoftwareProperties/dialog_add_sources_list.py
index cf8ddd95..b0a868b1 100644
--- a/SoftwareProperties/dialog_add_sources_list.py
+++ b/SoftwareProperties/dialog_add_sources_list.py
@@ -17,18 +17,18 @@ class AddSourcesList:
print file
self.parent = parent
self.source_renderer = source_renderer
- self.sources_old = sourceslist
+ self.sourceslist = sourceslist
self.get_comparable = get_comparable
self.file = self.format_uri(file)
self.glade = gtk.glade.XML(os.path.join(datadir,
"glade/SoftwarePropertiesDialogs.glade"))
self.glade.signal_autoconnect(self)
- self.dialog = self.glade.get_widget("dialog_sources_list")
+ self.dialog = self.glade.get_widget("dialog_add_sources_list")
self.label = self.glade.get_widget("label_sources")
self.button_add = self.glade.get_widget("button_add")
self.button_cancel = self.glade.get_widget("button_cancel")
+ self.button_replace = self.glade.get_widget("button_replace")
self.treeview = self.glade.get_widget("treeview_sources")
- self.button_close = self.glade.get_widget("button_close")
self.scrolled = self.glade.get_widget("scrolled_window")
self.image = self.glade.get_widget("image_sources_list")
@@ -51,24 +51,23 @@ class AddSourcesList:
# Parse the source.list file
try:
- self.sources = SingleSourcesList(self.file)
+ self.new_sources = SingleSourcesList(self.file)
except:
self.error()
return
# show the found channels or an error message
- if len(self.sources.list) > 0:
- self.button_close.hide()
+ if len(self.new_sources.list) > 0:
counter = 0
- for source in self.sources.list:
+ for source in self.new_sources.list:
if source.invalid or source.disabled:
continue
- self.sources.matcher.match(source)
+ self.new_sources.matcher.match(source)
# sort the list
- self.sources.list.sort(key=self.get_comparable)
+ self.new_sources.list.sort(key=self.get_comparable)
- for source in self.sources.list:
+ for source in self.new_sources.list:
if source.invalid or source.disabled:
continue
counter = counter +1
@@ -78,42 +77,35 @@ class AddSourcesList:
self.error()
return
- header = gettext.ngettext("Add the following software channel?",
- "Add the following software channels?",
+ header = gettext.ngettext("Install software additionally or "
+ "only from this source?",
+ "Install software additionally or "
+ "only from these sources?",
counter)
- body = _("You can install software from a channel. Use "\
- "trusted channels, only.")
+ body = _("You can either add the following sources or replace your "
+ "current sources by them. Only install software from "
+ "trusted sources.")
self.label.set_markup("<big><b>%s</b></big>\n\n%s" % (header, body))
- self.button_add.set_use_underline(True)
- self.button_add.set_label(gettext.ngettext("_Add Channel",
- "_Add Channels",
- counter))
else:
self.error()
return
def error(self):
self.button_add.hide()
- self.button_cancel.hide()
+ self.button_cancel.set_use_stock(True)
+ self.button_cancel.set_label("gtk-close")
+ self.button_replace.hide()
self.scrolled.hide()
- self.button_close.show()
self.image.set_from_stock(gtk.STOCK_DIALOG_ERROR, gtk.ICON_SIZE_DIALOG)
- header = _("Could not add any software channels")
+ header = _("There are no sources to install software from")
body = _("The file '%s' does not contain any valid "
- "software channels." % self.file)
+ "software sources." % self.file)
self.label.set_markup("<big><b>%s</b></big>\n\n%s" % (header, body))
def run(self):
res = self.dialog.run()
- if res == gtk.RESPONSE_OK:
- for source in self.sources:
- self.sources_old.add(source.type,
- source.uri,
- source.dist,
- source.comps,
- source.comment)
self.dialog.destroy()
- return res
+ return res, self.new_sources
def format_uri(self, uri):
path = urllib.url2pathname(uri) # escape special chars
diff --git a/data/glade/SoftwarePropertiesDialogs.glade b/data/glade/SoftwarePropertiesDialogs.glade
index e95d31e7..b4bf6180 100644
--- a/data/glade/SoftwarePropertiesDialogs.glade
+++ b/data/glade/SoftwarePropertiesDialogs.glade
@@ -895,7 +895,7 @@ You need a working internet connection to continue.</property>
</child>
</widget>
-<widget class="GtkDialog" id="dialog_sources_list">
+<widget class="GtkDialog" id="dialog_add_sources_list">
<property name="border_width">6</property>
<property name="title" translatable="yes"></property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
@@ -924,51 +924,41 @@ You need a working internet connection to continue.</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
- <widget class="GtkButton" id="button_cancel">
+ <widget class="GtkButton" id="button_replace">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
- <property name="label">gtk-cancel</property>
- <property name="use_stock">True</property>
+ <property name="label">_Replace</property>
+ <property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
- <property name="response_id">-6</property>
+ <property name="response_id">1</property>
</widget>
</child>
<child>
- <widget class="GtkButton" id="button_add">
+ <widget class="GtkButton" id="button_cancel">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
+ <property name="label">gtk-cancel</property>
+ <property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
- <property name="response_id">-5</property>
-
- <child>
- <widget class="GtkImage" id="image2">
- <property name="visible">True</property>
- <property name="stock">gtk-add</property>
- <property name="icon_size">4</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- </child>
+ <property name="response_id">-6</property>
</widget>
</child>
<child>
- <widget class="GtkButton" id="button_close">
+ <widget class="GtkButton" id="button_add">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
- <property name="label">gtk-close</property>
+ <property name="label">gtk-add</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
- <property name="response_id">-7</property>
+ <property name="response_id">2</property>
</widget>
</child>
</widget>