diff options
| author | Sebastian Heinlein <sebastian.heinlein@web.de> | 2006-03-13 17:34:22 +0100 |
|---|---|---|
| committer | Sebastian Heinlein <sebastian.heinlein@web.de> | 2006-03-13 17:34:22 +0100 |
| commit | e5957364bec1460ca4ae1ea48992c77653ea97be (patch) | |
| tree | 408544f75978382b4b8bbdf9d3edf1662803a830 | |
| parent | ae65c0496cc2c0a2451fbe6d551b36d1dba503c4 (diff) | |
| download | python-apt-e5957364bec1460ca4ae1ea48992c77653ea97be.tar.gz | |
* inform the user to update the cache if the channels have been modified.
provide a button to start synaptic in the dialog
| -rw-r--r-- | SoftwareProperties/SoftwareProperties.py | 10 | ||||
| -rw-r--r-- | SoftwareProperties/dialog_cache_outdated.py | 72 | ||||
| -rw-r--r-- | data/SoftwarePropertiesDialogs.glade | 1 |
3 files changed, 76 insertions, 7 deletions
diff --git a/SoftwareProperties/SoftwareProperties.py b/SoftwareProperties/SoftwareProperties.py index 95e5b5b3..41da0b32 100644 --- a/SoftwareProperties/SoftwareProperties.py +++ b/SoftwareProperties/SoftwareProperties.py @@ -38,6 +38,7 @@ from UpdateManager.Common.HelpViewer import HelpViewer import aptsources import dialog_add import dialog_edit +import dialog_cache_outdated from dialog_apt_key import apt_key from utils import * @@ -328,12 +329,9 @@ class SoftwareProperties(SimpleGladeApp): self.sourceslist.save() # show a dialog that a reload of the channel information is required if self.modified == True: - #res = self.dialog_cache_outofdate.run() - #if res == gtk.RESPONSE_ACCEPT: - # self.window_main.set_sensitive(False) - # FIXME DO SOME SYNAPTIC MAGIC - # self.window_main.set_sensitive(True) - pass + 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, diff --git a/SoftwareProperties/dialog_cache_outdated.py b/SoftwareProperties/dialog_cache_outdated.py new file mode 100644 index 00000000..11935519 --- /dev/null +++ b/SoftwareProperties/dialog_cache_outdated.py @@ -0,0 +1,72 @@ +# dialog_cache_outdated.py - inform the user to update the apt cache +# +# Copyright (c) 2006 Canonical +# +# Authors: +# Sebastian Heinlein <sebastian.heinlein@web.de> +# +# 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 +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA + +import os +import subprocess +import thread +import time +import gobject +import gtk +import gtk.glade +import apt_pkg + +class DialogCacheOutdated: + def __init__(self, parent, datadir): + """setup up the gtk dialog""" + self.parent = parent + + if os.path.exists("../data/SoftwarePropertiesDialogs.glade"): + self.gladexml = gtk.glade.XML("../data/SoftwarePropertiesDialogs.glade") + else: + self.gladexml = gtk.glade.XML("%s/glade/SoftwarePropertiesDialogs.glade" % datadir) + self.dialog = self.gladexml.get_widget("dialog_cache_outofdate") + self.dialog.set_transient_for(parent) + + def update_cache(self, window_id, lock): + """start synaptic to update the package cache""" + try: + apt_pkg.PkgSystemUnLock() + except SystemError: + pass + cmd = ["/usr/sbin/synaptic", "--hide-main-window", + "--non-interactive", + "--parent-window-id", "%s" % (id), + "--update-at-startup"] + subprocess.call(cmd) + lock.release() + + def run(self): + """run the dialog, and if reload was pressed run synaptic""" + res = self.dialog.run() + self.dialog.hide() + if res == gtk.RESPONSE_APPLY: + self.parent.set_sensitive(False) + lock = thread.allocate_lock() + lock.acquire() + t = thread.start_new_thread(self.update_cache, + (self.parent.window.xid, lock)) + while lock.locked(): + while gtk.events_pending(): + gtk.main_iteration() + time.sleep(0.05) + self.parent.set_sensitive(True) + return res diff --git a/data/SoftwarePropertiesDialogs.glade b/data/SoftwarePropertiesDialogs.glade index 7dab0228..d17f7ce5 100644 --- a/data/SoftwarePropertiesDialogs.glade +++ b/data/SoftwarePropertiesDialogs.glade @@ -988,7 +988,6 @@ Source</property> <widget class="GtkDialog" id="dialog_cache_outofdate"> <property name="border_width">6</property> - <property name="visible">True</property> <property name="title" translatable="yes"></property> <property name="type">GTK_WINDOW_TOPLEVEL</property> <property name="window_position">GTK_WIN_POS_NONE</property> |
