diff options
| -rw-r--r-- | SoftwareProperties/SoftwareProperties.py | 52 | ||||
| -rw-r--r-- | SoftwareProperties/dialog_add.py | 185 | ||||
| -rw-r--r-- | data/SoftwareProperties.glade | 1 | ||||
| -rw-r--r-- | data/SoftwarePropertiesDialogs.glade | 297 |
4 files changed, 65 insertions, 470 deletions
diff --git a/SoftwareProperties/SoftwareProperties.py b/SoftwareProperties/SoftwareProperties.py index 87a9aaad..14e570b9 100644 --- a/SoftwareProperties/SoftwareProperties.py +++ b/SoftwareProperties/SoftwareProperties.py @@ -751,12 +751,10 @@ class SoftwareProperties(SimpleGladeApp): def modified_sourceslist(self): """The sources list was changed and now needs to be saved and reloaded""" self.massive_debug_output() - #self.button_revert.set_sensitive(True) - #self.save_sourceslist() - #self.reload_sourceslist() self.modified = True - self.distro.get_sources(self.sourceslist) - self.distro_to_widgets() + #self.button_revert.set_sensitive(True) + self.save_sourceslist() + self.reload_sourceslist() def render_source(self, source): """Render a nice output to show the source in a treeview""" @@ -843,6 +841,13 @@ class SoftwareProperties(SimpleGladeApp): self.source_store.append([not source.disabled, contents, source, False, True]) + + if len(self.source_store) < 1: + self.button_remove.set_sensitive(False) + self.button_edit.set_sensitive(False) + else: + self.treeview_sources.set_cursor(0) + self.distro.get_sources(self.sourceslist) self.distro_to_widgets() def is_separator(self, model, iter, column): @@ -965,20 +970,14 @@ class SoftwareProperties(SimpleGladeApp): #shutil.copy(location, location + ".save") self.sourceslist.backup(".save") self.sourceslist.save() - # show a dialog that a reload of the channel information is required - # only if there is no parent defined - if self.modified == True and \ - self.options.toplevel == None: - d = dialog_cache_outdated.DialogCacheOutdated(self.window_main, - self.datadir) - res = d.run() def on_add_clicked(self, widget): dialog = dialog_add.dialog_add(self.window_main, self.sourceslist, self.datadir) - if dialog.run() == gtk.RESPONSE_OK: - self.reload_sourceslist() - self.modified = True + line = dialog.run() + if line != None: + self.sourceslist.list.append(aptsources.SourceEntry(line)) + self.modified_sourceslist() def on_edit_clicked(self, widget): sel = self.treeview_sources.get_selection() @@ -1024,14 +1023,14 @@ class SoftwareProperties(SimpleGladeApp): self.button_edit.set_sensitive(True) def on_remove_clicked(self, widget): - sel = self.treeview_sources.get_selection() - (model, iter) = sel.get_selected() + model = self.treeview_sources.get_model() + (path, column) = self.treeview_sources.get_cursor() + iter = model.get_iter(path) if iter: source = model.get_value(iter, LIST_ENTRY_OBJ) self.sourceslist.remove(source) - self.reload_sourceslist() - self.modified = True - + self.modified_sourceslist() + def add_key_clicked(self, widget): chooser = gtk.FileChooserDialog(title=_("Import key"), parent=self.window_main, @@ -1066,11 +1065,16 @@ class SoftwareProperties(SimpleGladeApp): self.reload_keyslist() def on_delete_event(self, widget, args): - self.save_sourceslist() - self.quit() - + self.on_close_button(self, widget) + def on_close_button(self, widget): - self.save_sourceslist() + # show a dialog that a reload of the channel information is required + # only if there is no parent defined + if self.modified == True and \ + self.options.toplevel == None: + d = dialog_cache_outdated.DialogCacheOutdated(self.window_main, + self.datadir) + res = d.run() self.quit() def on_help_button(self, widget): diff --git a/SoftwareProperties/dialog_add.py b/SoftwareProperties/dialog_add.py index b5fbe07f..81dd1cb2 100644 --- a/SoftwareProperties/dialog_add.py +++ b/SoftwareProperties/dialog_add.py @@ -6,7 +6,8 @@ # Authors: # Michael Vogt <mvo@debian.org> # Michiel Sikkes <michiels@gnome.org> -# +# Sebastian Heinlein <glatzor@ubuntu.com> +# # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of the @@ -29,167 +30,43 @@ import gtk.glade from gettext import gettext as _ import aptsources -import dialog_edit class dialog_add: - def __init__(self, parent, sourceslist, datadir, source_entry = None): + def __init__(self, parent, sourceslist, datadir): + """ + Initialize the dialog that allows to add a new source entering the + raw apt line + """ self.sourceslist = sourceslist self.parent = parent self.datadir = datadir - self.custom = False - # we have a source_entry that we want to modify - self.source_entry = source_entry - if source_entry: - self.source_entry_index = sourceslist.list.index(source_entry) - else: - self.source_entry_index = None - - # templates - self.templatelist = aptsources.SourceEntryTemplates(datadir) - - # FIXME: simple-glade-app should be able to do all this! - # gtk stuff - self.gladexml = gtk.glade.XML("%s/glade/SoftwarePropertiesDialogs.glade" % datadir) - - self.main = widget = self.gladexml.get_widget("dialog_add") - self.main.set_transient_for(self.parent) - - 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) - if source_entry: - self.main.set_title(_("Edit Channel")) - self.gladexml.get_widget("button_add").set_label("gtk-ok") - self.gladexml.signal_connect("on_button_custom_clicked", - self.on_button_custom_clicked, None) - + self.gladexml = gtk.glade.XML("%s/glade/SoftwarePropertiesDialogs.glade" %\ + datadir) + self.dialog = self.gladexml.get_widget("dialog_add_custom") + self.dialog.set_transient_for(self.parent) + self.entry = self.gladexml.get_widget("entry_source_line") + self.button_add = self.gladexml.get_widget("button_add_source") + self.entry.connect("changed", self.check_line) - def fill_combo(self,combo): - liststore = gtk.ListStore(gobject.TYPE_STRING,gobject.TYPE_PYOBJECT) - matched_template = None - for item in self.templatelist.templates: - liststore.append((item.description, item)) - if self.source_entry and item.matches(self.source_entry): - matched_template = item - combo.set_model(liststore) - if matched_template: - try: - combo.set_active(self.templatelist.templates.index(matched_template)) - vbox = self.gladexml.get_widget("vbox_comps") - for c in vbox.get_children(): - c.set_active(c.get_data("name") in self.source_entry.comps) - except ValueError: - pass + def run(self): + res = self.dialog.run() + self.dialog.hide() + if res == gtk.RESPONSE_OK: + line = self.entry.get_text() + "\n" else: - combo.set_active(0) - - def on_combobox_what_changed(self, combobox, user): - #print "on_combobox_what_changed" - vbox = self.gladexml.get_widget("vbox_comps") - vbox.foreach(lambda widget,vbox: vbox.remove(widget), vbox) - liststore = combobox.get_model() - a_iter = liststore.iter_nth_child(None, combobox.get_active()) - (name, template) = liststore.get(a_iter, 0,1) - self.selected = template - comps = template.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() + line = None + return line - def on_button_custom_clicked(self, widget, data): - #print "on_button_custom_clicked()" - # this hide here is ugly :/ - self.main.hide() - # check if we are in add or edit-matched mode - if self.source_entry: - # we are in "edit" mode - # get the SourceEntry as it is now (with local changes) - # and display the "old" edit dialog - self.selected_comps = [] - vbox = self.gladexml.get_widget("vbox_comps") - vbox.foreach(self.get_enabled_comps) - source_entry = self._make_source_entry() - # since we're passing the SourceEntry as it is now, - # this SourceEntry needs to be in the sourceslist, - # so temporarily swap the original for the current - if source_entry: - self.sourceslist.list[self.source_entry_index] = source_entry - dialog = dialog_edit.dialog_edit(self.parent, self.sourceslist, - source_entry, self.datadir) - res = dialog.run() - if res == gtk.RESPONSE_CANCEL: - # restore original SourceEntry - self.sourceslist.list[self.source_entry_index] = self.source_entry - elif res == gtk.RESPONSE_OK: - # the sourceslist is allready updated, but we'll overwrite it - # in self.run if we're not carefull - self.custom = True + def check_line(self, *args): + """ + Check for a valid apt line and set the sensitiveness of the + button 'add' accordingly + """ + 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: - # we are in "add" mode - 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.button_add.set_sensitive(True) - def get_enabled_comps(self, checkbutton): - if checkbutton.get_active(): - self.selected_comps.append(checkbutton.get_data("name")) - - def _make_source_entry(self): - " helper for the 'edit' mode " - # we use "selected" for pretty much everything *but* we use - # self.source_entry.uri to make sure that the mirror information is - # preserved - - line = "%s %s %s" % (self.selected.type, self.source_entry.uri, self.selected.dist) - if self.source_entry.disabled: - line = "#" + line - if len(self.selected.comps) > 0 and len(self.selected_comps) == 0: - line = "#" + line - elif len(self.selected_comps) > 0: - line += " " + " ".join(self.selected_comps) - if self.selected.matches(self.source_entry) and self.source_entry.comment != "": - line += " #"+self.source_entry.comment - line += "\n" - return aptsources.SourceEntry(line,self.source_entry.file) - - def run(self): - 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) - - # check if we are in 'add' or 'edit' mode - if self.source_entry: - # 'edit' - ode - # check if there are no selected components - if len(self.selected_comps) < 1: - # remove the source - self.sourceslist.remove(self.source_entry) - else: - if not self.custom: - entry = self._make_source_entry() - if entry: - self.sourceslist.list[self.source_entry_index] = entry - else: - # 'add' mode - self.sourceslist.add(self.selected.type, - self.selected.uri, - self.selected.dist, - self.selected_comps) - self.main.hide() - return res diff --git a/data/SoftwareProperties.glade b/data/SoftwareProperties.glade index b541ab65..9c63fd52 100644 --- a/data/SoftwareProperties.glade +++ b/data/SoftwareProperties.glade @@ -803,7 +803,6 @@ <child> <widget class="GtkButton" id="button1"> - <property name="visible">True</property> <property name="can_focus">True</property> <property name="label">gtk-revert-to-saved</property> <property name="use_stock">True</property> diff --git a/data/SoftwarePropertiesDialogs.glade b/data/SoftwarePropertiesDialogs.glade index 8c5b00c6..b381965b 100644 --- a/data/SoftwarePropertiesDialogs.glade +++ b/data/SoftwarePropertiesDialogs.glade @@ -3,292 +3,6 @@ <glade-interface> -<widget class="GtkDialog" id="dialog_add"> - <property name="border_width">6</property> - <property name="title" translatable="yes">Add Channel</property> - <property name="type">GTK_WINDOW_TOPLEVEL</property> - <property name="window_position">GTK_WIN_POS_NONE</property> - <property name="modal">True</property> - <property name="resizable">False</property> - <property name="destroy_with_parent">False</property> - <property name="decorated">True</property> - <property name="skip_taskbar_hint">True</property> - <property name="skip_pager_hint">False</property> - <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> - <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> - <property name="focus_on_map">True</property> - <property name="urgency_hint">False</property> - <property name="has_separator">False</property> - - <child internal-child="vbox"> - <widget class="GtkVBox" id="vbox2"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">12</property> - - <child internal-child="action_area"> - <widget class="GtkHButtonBox" id="hbuttonbox2"> - <property name="visible">True</property> - <property name="layout_style">GTK_BUTTONBOX_END</property> - - <child> - <widget class="GtkButton" id="button_custom"> - <property name="visible">True</property> - <property name="can_default">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">_Custom</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> - <signal name="clicked" handler="on_button_custom_clicked" last_modification_time="Mon, 29 Nov 2004 11:06:40 GMT"/> - </widget> - </child> - - <child> - <widget class="GtkButton" id="button2"> - <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">-6</property> - </widget> - </child> - - <child> - <widget class="GtkButton" id="button_add"> - <property name="visible">True</property> - <property name="can_default">True</property> - <property name="has_default">True</property> - <property name="can_focus">True</property> - <property name="has_focus">True</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">-5</property> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="pack_type">GTK_PACK_END</property> - </packing> - </child> - - <child> - <widget class="GtkVBox" id="vbox19"> - <property name="border_width">6</property> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">12</property> - - <child> - <widget class="GtkVBox" id="vbox20"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">6</property> - - <child> - <widget class="GtkLabel" id="label31"> - <property name="visible">True</property> - <property name="label" translatable="yes"><b>Channel</b></property> - <property name="use_underline">False</property> - <property name="use_markup">True</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkHBox" id="hbox35"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">0</property> - - <child> - <widget class="GtkLabel" id="label68"> - <property name="visible">True</property> - <property name="label" translatable="yes"> </property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkComboBox" id="combobox_what"> - <property name="visible">True</property> - <property name="add_tearoffs">False</property> - <property name="focus_on_click">True</property> - <signal name="changed" handler="on_combobox_what_changed" last_modification_time="Thu, 25 Nov 2004 13:35:11 GMT"/> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkVBox" id="vbox21"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">6</property> - - <child> - <widget class="GtkLabel" id="label32"> - <property name="visible">True</property> - <property name="label" translatable="yes"><b>Components</b></property> - <property name="use_underline">False</property> - <property name="use_markup">True</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkHBox" id="hbox34"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">0</property> - - <child> - <widget class="GtkLabel" id="label69"> - <property name="visible">True</property> - <property name="label" translatable="yes"> </property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkVBox" id="vbox_comps"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">6</property> - - <child> - <placeholder/> - </child> - - <child> - <placeholder/> - </child> - - <child> - <placeholder/> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - </child> -</widget> - <widget class="GtkDialog" id="dialog_add_custom"> <property name="border_width">6</property> <property name="title" translatable="yes"></property> @@ -331,8 +45,9 @@ </child> <child> - <widget class="GtkButton" id="button6"> + <widget class="GtkButton" id="button_add_source"> <property name="visible">True</property> + <property name="sensitive">False</property> <property name="can_default">True</property> <property name="has_default">True</property> <property name="can_focus">True</property> @@ -379,7 +94,7 @@ <child> <widget class="GtkLabel" id="label35"> <property name="visible">True</property> - <property name="label" translatable="yes">_Add Channel</property> + <property name="label" translatable="yes">_Add Source</property> <property name="use_underline">True</property> <property name="use_markup">False</property> <property name="justify">GTK_JUSTIFY_LEFT</property> @@ -449,9 +164,9 @@ <widget class="GtkLabel" id="label33"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="label" translatable="yes"><big><b>Enter the complete APT line of the channel that you want to add</b></big> + <property name="label" translatable="yes"><big><b>Enter the complete APT line of the source that you want to add</b></big> -The APT line includes the type, location and components of a channel, for example <i>"deb http://ftp.debian.org sarge main"</i>.</property> +The APT line includes the type, location and components of a source, for example <i>"deb http://ftp.debian.org sarge main"</i>.</property> <property name="use_underline">False</property> <property name="use_markup">True</property> <property name="justify">GTK_JUSTIFY_LEFT</property> @@ -549,7 +264,7 @@ The APT line includes the type, location and components of a channel, for exampl <widget class="GtkDialog" id="dialog_edit"> <property name="border_width">6</property> - <property name="title" translatable="yes">Edit Channel</property> + <property name="title" translatable="yes">Edit Source</property> <property name="type">GTK_WINDOW_TOPLEVEL</property> <property name="window_position">GTK_WIN_POS_NONE</property> <property name="modal">True</property> |
