Entry point 'desktop' for plugins managing desktop environment;
desktop_xdg will do it with pyxdg. Fixes: #857
This commit is contained in:
parent
74e039de5d
commit
c51108e867
8
setup.py
8
setup.py
|
@ -12,6 +12,7 @@ from src.version import softwareVersion
|
||||||
|
|
||||||
|
|
||||||
EXTRAS_REQUIRE = {
|
EXTRAS_REQUIRE = {
|
||||||
|
'docs': ['sphinx', 'sphinxcontrib-apidoc', 'm2r'],
|
||||||
'gir': ['pygobject'],
|
'gir': ['pygobject'],
|
||||||
'json': ['jsonrpclib'],
|
'json': ['jsonrpclib'],
|
||||||
'notify2': ['notify2'],
|
'notify2': ['notify2'],
|
||||||
|
@ -20,8 +21,8 @@ EXTRAS_REQUIRE = {
|
||||||
'qrcode': ['qrcode'],
|
'qrcode': ['qrcode'],
|
||||||
'sound;platform_system=="Windows"': ['winsound'],
|
'sound;platform_system=="Windows"': ['winsound'],
|
||||||
'tor': ['stem'],
|
'tor': ['stem'],
|
||||||
'xml': ['defusedxml'],
|
'xdg': ['pyxdg'],
|
||||||
'docs': ['sphinx', 'sphinxcontrib-apidoc', 'm2r']
|
'xml': ['defusedxml']
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -153,6 +154,9 @@ if __name__ == "__main__":
|
||||||
'libmessaging ='
|
'libmessaging ='
|
||||||
'pybitmessage.plugins.indicator_libmessaging [gir]'
|
'pybitmessage.plugins.indicator_libmessaging [gir]'
|
||||||
],
|
],
|
||||||
|
'bitmessage.desktop': [
|
||||||
|
'freedesktop = pybitmessage.plugins.desktop_xdg [xdg]'
|
||||||
|
],
|
||||||
'bitmessage.proxyconfig': [
|
'bitmessage.proxyconfig': [
|
||||||
'stem = pybitmessage.plugins.proxyconfig_stem [tor]'
|
'stem = pybitmessage.plugins.proxyconfig_stem [tor]'
|
||||||
],
|
],
|
||||||
|
|
|
@ -640,8 +640,6 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
BMConfigParser().remove_section(addressInKeysFile)
|
BMConfigParser().remove_section(addressInKeysFile)
|
||||||
BMConfigParser().save()
|
BMConfigParser().save()
|
||||||
|
|
||||||
self.updateStartOnLogon()
|
|
||||||
|
|
||||||
self.change_translation()
|
self.change_translation()
|
||||||
|
|
||||||
# e.g. for editing labels
|
# e.g. for editing labels
|
||||||
|
@ -826,6 +824,7 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
self.sqlInit()
|
self.sqlInit()
|
||||||
self.indicatorInit()
|
self.indicatorInit()
|
||||||
self.notifierInit()
|
self.notifierInit()
|
||||||
|
self.updateStartOnLogon()
|
||||||
|
|
||||||
self.ui.updateNetworkSwitchMenuLabel()
|
self.ui.updateNetworkSwitchMenuLabel()
|
||||||
|
|
||||||
|
@ -844,26 +843,25 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
self._contact_selected = None
|
self._contact_selected = None
|
||||||
|
|
||||||
def updateStartOnLogon(self):
|
def updateStartOnLogon(self):
|
||||||
# Configure Bitmessage to start on startup (or remove the
|
"""
|
||||||
# configuration) based on the setting in the keys.dat file
|
Configure Bitmessage to start on startup (or remove the
|
||||||
|
configuration) based on the setting in the keys.dat file
|
||||||
|
"""
|
||||||
|
startonlogon = BMConfigParser().safeGetBoolean(
|
||||||
|
'bitmessagesettings', 'startonlogon')
|
||||||
if 'win32' in sys.platform or 'win64' in sys.platform:
|
if 'win32' in sys.platform or 'win64' in sys.platform:
|
||||||
# Auto-startup for Windows
|
# Auto-startup for Windows
|
||||||
RUN_PATH = "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run"
|
RUN_PATH = "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run"
|
||||||
self.settings = QtCore.QSettings(
|
settings = QtCore.QSettings(
|
||||||
RUN_PATH, QtCore.QSettings.NativeFormat)
|
RUN_PATH, QtCore.QSettings.NativeFormat)
|
||||||
# In case the user moves the program and the registry entry is
|
# In case the user moves the program and the registry entry is
|
||||||
# no longer valid, this will delete the old registry entry.
|
# no longer valid, this will delete the old registry entry.
|
||||||
self.settings.remove("PyBitmessage")
|
if startonlogon:
|
||||||
if BMConfigParser().getboolean(
|
settings.setValue("PyBitmessage", sys.argv[0])
|
||||||
'bitmessagesettings', 'startonlogon'
|
else:
|
||||||
):
|
settings.remove("PyBitmessage")
|
||||||
self.settings.setValue("PyBitmessage", sys.argv[0])
|
elif self.desktop:
|
||||||
elif 'darwin' in sys.platform:
|
self.desktop.adjust_startonlogon(startonlogon)
|
||||||
# startup for mac
|
|
||||||
pass
|
|
||||||
elif 'linux' in sys.platform:
|
|
||||||
# startup for linux
|
|
||||||
pass
|
|
||||||
|
|
||||||
def updateTTL(self, sliderPosition):
|
def updateTTL(self, sliderPosition):
|
||||||
TTL = int(sliderPosition ** 3.199 + 3600)
|
TTL = int(sliderPosition ** 3.199 + 3600)
|
||||||
|
@ -1423,12 +1421,21 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
def sqlInit(self):
|
def sqlInit(self):
|
||||||
register_adapter(QtCore.QByteArray, str)
|
register_adapter(QtCore.QByteArray, str)
|
||||||
|
|
||||||
# Try init the distro specific appindicator,
|
|
||||||
# for example the Ubuntu MessagingMenu
|
|
||||||
def indicatorInit(self):
|
def indicatorInit(self):
|
||||||
|
"""
|
||||||
|
Try init the distro specific appindicator,
|
||||||
|
for example the Ubuntu MessagingMenu
|
||||||
|
"""
|
||||||
def _noop_update(*args, **kwargs):
|
def _noop_update(*args, **kwargs):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# get desktop plugin if any
|
||||||
|
if 'win' not in sys.platform:
|
||||||
|
try:
|
||||||
|
self.desktop = get_plugin('desktop')()
|
||||||
|
except TypeError:
|
||||||
|
self.desktop = False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.indicatorUpdate = get_plugin('indicator')(self)
|
self.indicatorUpdate = get_plugin('indicator')(self)
|
||||||
except (NameError, TypeError):
|
except (NameError, TypeError):
|
||||||
|
|
|
@ -119,9 +119,6 @@ class SettingsDialog(QtGui.QDialog):
|
||||||
self.checkBoxPortableMode.setDisabled(True)
|
self.checkBoxPortableMode.setDisabled(True)
|
||||||
|
|
||||||
if 'darwin' in sys.platform:
|
if 'darwin' in sys.platform:
|
||||||
self.checkBoxStartOnLogon.setDisabled(True)
|
|
||||||
self.checkBoxStartOnLogon.setText(_translate(
|
|
||||||
"MainWindow", "Start-on-login not yet supported on your OS."))
|
|
||||||
self.checkBoxMinimizeToTray.setDisabled(True)
|
self.checkBoxMinimizeToTray.setDisabled(True)
|
||||||
self.checkBoxMinimizeToTray.setText(_translate(
|
self.checkBoxMinimizeToTray.setText(_translate(
|
||||||
"MainWindow",
|
"MainWindow",
|
||||||
|
@ -130,10 +127,12 @@ class SettingsDialog(QtGui.QDialog):
|
||||||
self.checkBoxShowTrayNotifications.setText(_translate(
|
self.checkBoxShowTrayNotifications.setText(_translate(
|
||||||
"MainWindow",
|
"MainWindow",
|
||||||
"Tray notifications not yet supported on your OS."))
|
"Tray notifications not yet supported on your OS."))
|
||||||
elif 'linux' in sys.platform:
|
|
||||||
|
if 'win' not in sys.platform and not self.parent.desktop:
|
||||||
self.checkBoxStartOnLogon.setDisabled(True)
|
self.checkBoxStartOnLogon.setDisabled(True)
|
||||||
self.checkBoxStartOnLogon.setText(_translate(
|
self.checkBoxStartOnLogon.setText(_translate(
|
||||||
"MainWindow", "Start-on-login not yet supported on your OS."))
|
"MainWindow", "Start-on-login not yet supported on your OS."))
|
||||||
|
|
||||||
# On the Network settings tab:
|
# On the Network settings tab:
|
||||||
self.lineEditTCPPort.setText(str(
|
self.lineEditTCPPort.setText(str(
|
||||||
config.get('bitmessagesettings', 'port')))
|
config.get('bitmessagesettings', 'port')))
|
||||||
|
|
31
src/plugins/desktop_xdg.py
Normal file
31
src/plugins/desktop_xdg.py
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
from xdg import BaseDirectory, Menu
|
||||||
|
|
||||||
|
|
||||||
|
class DesktopXDG(object):
|
||||||
|
"""pyxdg Freedesktop desktop implementation"""
|
||||||
|
def __init__(self):
|
||||||
|
menu_entry = Menu.parse().getMenu('Office').getMenuEntry(
|
||||||
|
'pybitmessage.desktop')
|
||||||
|
self.desktop = menu_entry.DesktopEntry if menu_entry else None
|
||||||
|
|
||||||
|
def adjust_startonlogon(self, autostart=False):
|
||||||
|
"""Configure autostart according to settings"""
|
||||||
|
if not self.desktop:
|
||||||
|
return
|
||||||
|
|
||||||
|
autostart_path = os.path.join(
|
||||||
|
BaseDirectory.xdg_config_home, 'autostart', 'pybitmessage.desktop')
|
||||||
|
if autostart:
|
||||||
|
self.desktop.write(autostart_path)
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
os.remove(autostart_path)
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
connect_plugin = DesktopXDG
|
Reference in New Issue
Block a user