File: CdromProgress.py

package info (click to toggle)
software-properties 0.111-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 6,944 kB
  • sloc: python: 8,238; makefile: 19; sh: 18; xml: 10
file content (61 lines) | stat: -rw-r--r-- 2,350 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#  Qt 4 based frontend to software-properties
#
#  Copyright (c) 2007 Canonical Ltd.
#
#  Author: Jonathan Riddell <jriddell@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
#  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 apt
from PyQt6.QtCore import *
from PyQt6.QtGui import *
from gettext import gettext as _
from .I18nHelper import *

class CdromProgress(apt.progress.base.CdromProgress):
  def __init__(self, datadir, parent, kapp):
    self.dialog_cdrom_progress = QProgressDialog(parent.userinterface)
    self.button_cdrom_close = QPushButton("Close", None)
    self.dialog_cdrom_progress.setCancelButton(self.button_cdrom_close)
    self.dialog_cdrom_progress.show()
    self.parent = parent
    self.kapp = kapp
    self.button_cdrom_close.setEnabled(False)

  def close(self):
    self.dialog_cdrom_progress.close()

  def update(self, text, step):
    """ update is called regularly so that the gui can be redrawn """
    if step > 0:
      self.dialog_cdrom_progress.setValue(int((step/self.total_steps)*100))
      if step == self.total_steps:
        self.button_cdrom_close.setEnabled(True)
    if text != "":
      self.dialog_cdrom_progress.setLabelText(text)
    self.kapp.processEvents()

  def askCdromName(self):
    (name, valid) = QInputDialog.getText(self.parent.userinterface, _("CD Name"), _("Please enter a name for the disc"))
    return (valid, name)

  def changeCdrom(self):
    result = QMessageBox.question(self.parent.userinterface, _("Insert Disk"), _("Please insert a disk in the drive:"), QMessageBox.StandardButton.Ok|QMessageBox.StandardButton.Cancel)
    if result == QMessageBox.StandardButton.Ok:
      print("ok")
      return True
    print("cancel")
    return False