Other basic fixes to avoid crashing. Release 3.0.2
This commit is contained in:
parent
bb3c73f8c8
commit
93a7dcc4a1
@ -9,11 +9,13 @@ import os
|
|||||||
import gettext
|
import gettext
|
||||||
import libproxy
|
import libproxy
|
||||||
from PyQt5.QtCore import pyqtSignal
|
from PyQt5.QtCore import pyqtSignal
|
||||||
from PyQt5 import QtGui
|
from PyQt5.QtGui import QIcon
|
||||||
from PyQt5 import QtWidgets
|
from PyQt5.QtWidgets import QSystemTrayIcon, QApplication, QMenu, QMainWindow, QMessageBox, QWidget
|
||||||
from PyQt5 import QtCore
|
from PyQt5 import QtCore
|
||||||
|
|
||||||
class SystemTrayIcon(QtWidgets.QSystemTrayIcon):
|
class SystemTrayIcon(QSystemTrayIcon):
|
||||||
|
|
||||||
|
context_menu = None
|
||||||
|
|
||||||
def __init__(self, icon, parent=None):
|
def __init__(self, icon, parent=None):
|
||||||
global w, menu, contatore, srpm, lista, NetsrpmsArg, nOre, desktop_session
|
global w, menu, contatore, srpm, lista, NetsrpmsArg, nOre, desktop_session
|
||||||
@ -23,8 +25,8 @@ class SystemTrayIcon(QtWidgets.QSystemTrayIcon):
|
|||||||
lista = []
|
lista = []
|
||||||
contatore = 0
|
contatore = 0
|
||||||
w = parent
|
w = parent
|
||||||
QtWidgets.QSystemTrayIcon.__init__(self, icon, parent)
|
QSystemTrayIcon.__init__(self, icon, parent)
|
||||||
menu = QtWidgets.QMenu(parent)
|
menu = QMenu(parent)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
desktop_session = os.path.basename(os.getenv('DESKTOP_SESSION'))
|
desktop_session = os.path.basename(os.getenv('DESKTOP_SESSION'))
|
||||||
@ -54,14 +56,14 @@ class SystemTrayIcon(QtWidgets.QSystemTrayIcon):
|
|||||||
softwareBaseInstallsProcess = QtCore.QProcess(self)
|
softwareBaseInstallsProcess = QtCore.QProcess(self)
|
||||||
dcopServerProcess = QtCore.QProcess(self)
|
dcopServerProcess = QtCore.QProcess(self)
|
||||||
|
|
||||||
softwareMenu = menu.addMenu(QtGui.QIcon.fromTheme("applications-system"),_("Software"))
|
softwareMenu = menu.addMenu(QIcon.fromTheme("applications-system"),_("Software"))
|
||||||
softwareManageAction = softwareMenu.addAction(QtGui.QIcon.fromTheme("applications-other"),_("Add/Remove software packages..."))
|
softwareManageAction = softwareMenu.addAction(QIcon.fromTheme("applications-other"),_("Add/Remove software packages..."))
|
||||||
softwareManageAction.triggered.connect(self.softwareManager)
|
softwareManageAction.triggered.connect(self.softwareManager)
|
||||||
|
|
||||||
softwareCheckUpgradesAction = softwareMenu.addAction(QtGui.QIcon.fromTheme("system-software-update"),_("Check for updates now..."))
|
softwareCheckUpgradesAction = softwareMenu.addAction(QIcon.fromTheme("system-software-update"),_("Check for updates now..."))
|
||||||
softwareCheckUpgradesAction.triggered.connect(self.softwareCheckUpgrades)
|
softwareCheckUpgradesAction.triggered.connect(self.softwareCheckUpgrades)
|
||||||
|
|
||||||
softwareBaseInstallsAction = softwareMenu.addAction(QtGui.QIcon.fromTheme("openmamba"),_("openmamba components..."))
|
softwareBaseInstallsAction = softwareMenu.addAction(QIcon.fromTheme("openmamba"),_("openmamba components..."))
|
||||||
softwareBaseInstallsAction.triggered.connect(self.softwareBaseInstalls)
|
softwareBaseInstallsAction.triggered.connect(self.softwareBaseInstalls)
|
||||||
|
|
||||||
# network menu
|
# network menu
|
||||||
@ -71,27 +73,27 @@ class SystemTrayIcon(QtWidgets.QSystemTrayIcon):
|
|||||||
networkFirewallConfigureProcess = QtCore.QProcess(self)
|
networkFirewallConfigureProcess = QtCore.QProcess(self)
|
||||||
networkProxyProcess = QtCore.QProcess(self)
|
networkProxyProcess = QtCore.QProcess(self)
|
||||||
|
|
||||||
networkMenu = menu.addMenu(QtGui.QIcon.fromTheme("preferences-system-network"),_("Network"))
|
networkMenu = menu.addMenu(QIcon.fromTheme("preferences-system-network"),_("Network"))
|
||||||
networkFirewallMenu = networkMenu.addMenu(QtGui.QIcon.fromTheme("security-medium"),_("Firewall"))
|
networkFirewallMenu = networkMenu.addMenu(QIcon.fromTheme("security-medium"),_("Firewall"))
|
||||||
networkFirewallDisableAction = networkFirewallMenu.addAction(QtGui.QIcon.fromTheme("security-low"),_("Disable"))
|
networkFirewallDisableAction = networkFirewallMenu.addAction(QIcon.fromTheme("security-low"),_("Disable"))
|
||||||
networkFirewallDisableAction.triggered.connect(self.networkFirewallDisable)
|
networkFirewallDisableAction.triggered.connect(self.networkFirewallDisable)
|
||||||
networkFirewallDisableProcess.finished.connect(self.networkFirewallDisableMessage)
|
networkFirewallDisableProcess.finished.connect(self.networkFirewallDisableMessage)
|
||||||
networkFirewallEnableAction = networkFirewallMenu.addAction(QtGui.QIcon.fromTheme("security-high"),_("Enable"))
|
networkFirewallEnableAction = networkFirewallMenu.addAction(QIcon.fromTheme("security-high"),_("Enable"))
|
||||||
networkFirewallEnableAction.triggered.connect(self.networkFirewallEnable)
|
networkFirewallEnableAction.triggered.connect(self.networkFirewallEnable)
|
||||||
networkFirewallEnableProcess.finished.connect(self.networkFirewallEnableMessage)
|
networkFirewallEnableProcess.finished.connect(self.networkFirewallEnableMessage)
|
||||||
networkFirewallConfigureAction = networkFirewallMenu.addAction(QtGui.QIcon.fromTheme("security-medium"),_("Configure..."))
|
networkFirewallConfigureAction = networkFirewallMenu.addAction(QIcon.fromTheme("security-medium"),_("Configure..."))
|
||||||
networkFirewallConfigureAction.triggered.connect(self.networkFirewallConfigure)
|
networkFirewallConfigureAction.triggered.connect(self.networkFirewallConfigure)
|
||||||
networkProxyAction = networkMenu.addAction(QtGui.QIcon.fromTheme("network-server"),_("Proxy..."))
|
networkProxyAction = networkMenu.addAction(QIcon.fromTheme("network-server"),_("Proxy..."))
|
||||||
networkProxyAction.triggered.connect(self.networkProxy)
|
networkProxyAction.triggered.connect(self.networkProxy)
|
||||||
SRPMUpdateProcess.finished.connect(self.SRPMSCheckUpgrade)
|
SRPMUpdateProcess.finished.connect(self.SRPMSCheckUpgrade)
|
||||||
|
|
||||||
|
|
||||||
# about box
|
# about box
|
||||||
aboutAction = menu.addSeparator()
|
aboutAction = menu.addSeparator()
|
||||||
aboutAction = menu.addAction(QtGui.QIcon.fromTheme("help-about"),_("About"))
|
aboutAction = menu.addAction(QIcon.fromTheme("help-about"),_("About"))
|
||||||
aboutAction.triggered.connect(self.about)
|
aboutAction.triggered.connect(self.about)
|
||||||
|
|
||||||
self.setContextMenu(menu)
|
self.context_menu = menu
|
||||||
self.setToolTip(_("openmamba control center"))
|
self.setToolTip(_("openmamba control center"))
|
||||||
self.activated.connect(self.iconActivated)
|
self.activated.connect(self.iconActivated)
|
||||||
|
|
||||||
@ -115,7 +117,7 @@ class SystemTrayIcon(QtWidgets.QSystemTrayIcon):
|
|||||||
break
|
break
|
||||||
|
|
||||||
def iconActivated(self, reason):
|
def iconActivated(self, reason):
|
||||||
if reason in (QtWidgets.QSystemTrayIcon.Trigger, QtWidgets.QSystemTrayIcon.DoubleClick):
|
if reason in (QSystemTrayIcon.Trigger, QSystemTrayIcon.DoubleClick):
|
||||||
menu.popup(self.geometry().center())
|
menu.popup(self.geometry().center())
|
||||||
|
|
||||||
def about(self):
|
def about(self):
|
||||||
@ -129,7 +131,7 @@ class SystemTrayIcon(QtWidgets.QSystemTrayIcon):
|
|||||||
v.close()
|
v.close()
|
||||||
else:
|
else:
|
||||||
version = _("Error: Unable to find /etc/openmamba-release")
|
version = _("Error: Unable to find /etc/openmamba-release")
|
||||||
QtWidgets.QMessageBox.about(menu, _("About"),
|
QMessageBox.about(menu, _("About"),
|
||||||
"<center><b>"+_("openmamba control center")+"</b>"
|
"<center><b>"+_("openmamba control center")+"</b>"
|
||||||
"<br><br>Copyright(c) 2011-2019 by Silvan Calarco"
|
"<br><br>Copyright(c) 2011-2019 by Silvan Calarco"
|
||||||
"<br>Copyright(c) 2011 by michiamophil"
|
"<br>Copyright(c) 2011 by michiamophil"
|
||||||
@ -149,7 +151,7 @@ class SystemTrayIcon(QtWidgets.QSystemTrayIcon):
|
|||||||
return networkOnlineProcess.execute("/usr/bin/nm-online",['-q','-x'])
|
return networkOnlineProcess.execute("/usr/bin/nm-online",['-q','-x'])
|
||||||
|
|
||||||
def softwareManager(self):
|
def softwareManager(self):
|
||||||
self.setProxyForSmart()
|
#self.setProxyForSmart()
|
||||||
if desktop_session == 'plasma':
|
if desktop_session == 'plasma':
|
||||||
softwareManagerProcess.execute("/usr/bin/plasma-discover", ['--mode', 'Browsing'])
|
softwareManagerProcess.execute("/usr/bin/plasma-discover", ['--mode', 'Browsing'])
|
||||||
elif desktop_session == 'kde':
|
elif desktop_session == 'kde':
|
||||||
@ -158,7 +160,7 @@ class SystemTrayIcon(QtWidgets.QSystemTrayIcon):
|
|||||||
softwareManagerProcess.execute("/usr/bin/gpk-application")
|
softwareManagerProcess.execute("/usr/bin/gpk-application")
|
||||||
|
|
||||||
def softwareCheckUpgrades(self):
|
def softwareCheckUpgrades(self):
|
||||||
self.setProxyForSmart()
|
#self.setProxyForSmart()
|
||||||
if desktop_session == 'plasma':
|
if desktop_session == 'plasma':
|
||||||
softwareCheckUpgradesProcess.start("/usr/bin/plasma-discover", ['--mode', 'Update'])
|
softwareCheckUpgradesProcess.start("/usr/bin/plasma-discover", ['--mode', 'Update'])
|
||||||
elif desktop_session == 'kde':
|
elif desktop_session == 'kde':
|
||||||
@ -167,7 +169,7 @@ class SystemTrayIcon(QtWidgets.QSystemTrayIcon):
|
|||||||
softwareCheckUpgradesProcess.start("/usr/bin/gpk-update-viewer")
|
softwareCheckUpgradesProcess.start("/usr/bin/gpk-update-viewer")
|
||||||
|
|
||||||
def refreshPackagesCache(self):
|
def refreshPackagesCache(self):
|
||||||
self.setProxyForSmart()
|
#self.setProxyForSmart()
|
||||||
refreshPackagesTimer.stop()
|
refreshPackagesTimer.stop()
|
||||||
refreshPackagesCacheProcess.start("/usr/bin/pkcon", ['refresh'])
|
refreshPackagesCacheProcess.start("/usr/bin/pkcon", ['refresh'])
|
||||||
|
|
||||||
@ -210,7 +212,7 @@ class SystemTrayIcon(QtWidgets.QSystemTrayIcon):
|
|||||||
networkProxyProcess.execute("/opt/kde/bin/kcmshell4", list(set(['proxy'])))
|
networkProxyProcess.execute("/opt/kde/bin/kcmshell4", list(set(['proxy'])))
|
||||||
elif desktop_session == 'gnome':
|
elif desktop_session == 'gnome':
|
||||||
networkProxyProcess.execute("/usr/bin/gnome-control-center", "network")
|
networkProxyProcess.execute("/usr/bin/gnome-control-center", "network")
|
||||||
self.setProxyForSmart()
|
#self.setProxyForSmart()
|
||||||
|
|
||||||
def SRPMSCheckUpgradeList(self):
|
def SRPMSCheckUpgradeList(self):
|
||||||
checkSRPMSUpdatesTimer.stop()
|
checkSRPMSUpdatesTimer.stop()
|
||||||
@ -240,8 +242,8 @@ class SystemTrayIcon(QtWidgets.QSystemTrayIcon):
|
|||||||
global NetsrpmsArg, lista
|
global NetsrpmsArg, lista
|
||||||
if not lista == []:
|
if not lista == []:
|
||||||
Lista = self.Lista()
|
Lista = self.Lista()
|
||||||
msg = QtWidgets.QMessageBox.question(menu, (_("Not Open Source openmamba components")), (_("The following components are available for update: ") + "\n\n" + Lista + "\n\n" + _("Ok to proceed?")), QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No, QtWidgets.QMessageBox.Yes)
|
msg = QMessageBox.question(menu, (_("Not Open Source openmamba components")), (_("The following components are available for update: ") + "\n\n" + Lista + "\n\n" + _("Ok to proceed?")), QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes)
|
||||||
if msg == QtWidgets.QMessageBox.Yes:
|
if msg == QMessageBox.Yes:
|
||||||
NetsrpmsArg = '-u'
|
NetsrpmsArg = '-u'
|
||||||
self.SRPMSCheckUpgradeList()
|
self.SRPMSCheckUpgradeList()
|
||||||
else:
|
else:
|
||||||
@ -257,18 +259,22 @@ class SystemTrayIcon(QtWidgets.QSystemTrayIcon):
|
|||||||
testo = testo + a + ', '
|
testo = testo + a + ', '
|
||||||
return testo[0:len(testo)-2]
|
return testo[0:len(testo)-2]
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
app = QtWidgets.QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
if (app.isSessionRestored()):
|
if (app.isSessionRestored()):
|
||||||
app.exit(1)
|
app.exit(1)
|
||||||
else:
|
else:
|
||||||
app.setQuitOnLastWindowClosed(0)
|
app.setQuitOnLastWindowClosed(0)
|
||||||
gettext.install('mambatray', '/usr/share/locale')
|
gettext.install('mambatray', '/usr/share/locale')
|
||||||
w = QtWidgets.QWidget()
|
w = QWidget()
|
||||||
w.setWindowIcon(QtGui.QIcon.fromTheme("mambatray",QtGui.QIcon("/usr/share/icons/hicolor/64x64/apps/mambatray.png")))
|
w.setWindowIcon(QIcon.fromTheme("mambatray",QIcon("/usr/share/icons/hicolor/64x64/apps/mambatray.png")))
|
||||||
trayIcon = SystemTrayIcon(QtGui.QIcon.fromTheme("mambatray", QtGui.QIcon("/usr/share/icons/hicolor/32x32/apps/mambatray.png")), w)
|
trayIcon = SystemTrayIcon(QIcon.fromTheme("mambatray", QIcon("/usr/share/icons/hicolor/32x32/apps/mambatray.png")), w)
|
||||||
trayIcon.show()
|
trayIcon.show()
|
||||||
|
trayIcon.setContextMenu(menu)
|
||||||
|
trayIcon.setVisible(True)
|
||||||
sys.exit(app.exec_())
|
sys.exit(app.exec_())
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
Loading…
Reference in New Issue
Block a user