1
# Qt 4 based frontend to software-properties
3
# Copyright (c) 2007 Canonical Ltd.
5
# Author: Jonathan Riddell <jriddell@ubuntu.com>
7
# This program is free software; you can redistribute it and/or
8
# modify it under the terms of the GNU General Public License as
9
# published by the Free Software Foundation; either version 2 of the
10
# License, or (at your option) any later version.
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
17
# You should have received a copy of the GNU General Public License
18
# along with this program; if not, write to the Free Software
19
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22
from __future__ import absolute_import
24
from gettext import gettext as _
26
from PyQt5.QtCore import *
27
from PyQt5.QtGui import *
30
from aptsources.sourceslist import SourceEntry
32
from .I18nHelper import *
34
UIDIR = '/home/jr/src/software-properties/deneutral'
36
class DialogAdd(QDialog):
38
def __init__(self, parent, sourceslist, datadir, distro):
39
QDialog.__init__(self, parent)
40
self.sourceslist = sourceslist
42
uic.loadUi("%s/designer/dialog_add.ui" % datadir, self)
44
self.button_edit_ok = self.buttonBox.button(QDialogButtonBox.Ok)
45
self.button_edit_ok.setEnabled(False)
48
example = "%s %s %s %s" % (self.distro.binary_type,
49
self.distro.source_template.base_uri,
51
self.distro.source_template.components[0].name)
53
example = "deb http://ftp.debian.org sarge main"
54
# L10N: the example is of the format: deb http://ftp.debian.org sarge main
55
primary = _('Enter the complete APT line of the repository that '
57
secondary = _("Include the type, location and components of the "
58
"repository. Example: %s") % example
59
text = "%s<br /><br /><small>%s</small>" % (primary, secondary)
60
self.label_example_line.setWordWrap(True)
61
self.label_example_line.setText(text)
63
translate_widget(self)
65
self.entry.textChanged.connect(self.check_line)
67
def check_line(self, text):
68
"""Check for a valid apt line and set the enabled value of the
69
button 'add' accordingly"""
70
line = self.entry.text()
71
if line.startswith("ppa:"):
72
self.button_edit_ok.setEnabled(True)
74
source_entry = SourceEntry(line)
75
if source_entry.invalid == True or source_entry.disabled == True:
76
self.button_edit_ok.setEnabled(False)
78
self.button_edit_ok.setEnabled(True)
82
if result == QDialog.Accepted:
83
line = self.entry.text()