home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / pyshared / softwareproperties / gtk / CdromProgress.py next >
Encoding:
Python Source  |  2009-03-27  |  3.0 KB  |  80 lines

  1. #  GtkCdomProgress - add a cdrom to the apt sources
  2. #
  3. #  Copyright (c) 2004-2007 Canonical Ltd.
  4. #                2004-2005 Michiel Sikkes
  5. #
  6. #  Author: Michael Vogt <mvo@debian.org>
  7. #
  8. #  This program is free software; you can redistribute it and/or
  9. #  modify it under the terms of the GNU General Public License as
  10. #  published by the Free Software Foundation; either version 2 of the
  11. #  License, or (at your option) any later version.
  12. #
  13. #  This program is distributed in the hope that it will be useful,
  14. #  but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. #  GNU General Public License for more details.
  17. #
  18. #  You should have received a copy of the GNU General Public License
  19. #  along with this program; if not, write to the Free Software
  20. #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  21. #  USA
  22. import apt
  23. import gtk
  24. import gtk.glade
  25. from softwareproperties.gtk.SimpleGladeApp import SimpleGladeApp
  26. from gettext import gettext as _
  27.  
  28. class CdromProgress(apt.progress.CdromProgress, SimpleGladeApp):
  29.   def __init__(self,datadir, parent):
  30.     SimpleGladeApp.__init__(self,
  31.                             datadir+"glade/dialogs.glade",
  32.                             "dialog_cdrom_progress",
  33.                             domain="update-manager")
  34.     self.dialog_cdrom_progress.show()
  35.     self.dialog_cdrom_progress.set_transient_for(parent)
  36.     self.parent = parent
  37.     self.button_cdrom_close.set_sensitive(False)
  38.   def close(self):
  39.     self.dialog_cdrom_progress.hide()
  40.   def on_button_cdrom_close_clicked(self, widget):
  41.     self.close()
  42.   def update(self, text, step):
  43.     """ update is called regularly so that the gui can be redrawn """
  44.     if step > 0:
  45.       self.progressbar_cdrom.set_fraction(step/float(self.totalSteps))
  46.       if step == self.totalSteps:
  47.         self.button_cdrom_close.set_sensitive(True)
  48.     if text != "":
  49.       self.label_cdrom.set_text(text)
  50.     while gtk.events_pending():
  51.       gtk.main_iteration()
  52.   def askCdromName(self):
  53.     dialog = gtk.MessageDialog(parent=self.dialog_cdrom_progress,
  54.                                flags=gtk.DIALOG_MODAL,
  55.                                type=gtk.MESSAGE_QUESTION,
  56.                                buttons=gtk.BUTTONS_OK_CANCEL,
  57.                                message_format=None)
  58.     dialog.set_markup(_("Please enter a name for the disc"))
  59.     entry = gtk.Entry()
  60.     entry.show()
  61.     dialog.vbox.pack_start(entry)
  62.     res = dialog.run()
  63.     dialog.destroy()
  64.     if res == gtk.RESPONSE_OK:
  65.       name = entry.get_text()
  66.       return (True,name)
  67.     return (False,"")
  68.   def changeCdrom(self):
  69.     dialog = gtk.MessageDialog(parent=self.dialog_cdrom_progress,
  70.                                flags=gtk.DIALOG_MODAL,
  71.                                type=gtk.MESSAGE_QUESTION,
  72.                                buttons=gtk.BUTTONS_OK_CANCEL,
  73.                                message_format=None)
  74.     dialog.set_markup(_("Please insert a disk in the drive:"))
  75.     res = dialog.run()
  76.     dialog.destroy()
  77.     if res == gtk.RESPONSE_OK:
  78.       return True
  79.     return False
  80.