Skip to content

Commit

Permalink
Cleanup code a bit, remove unused stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
falkTX committed Aug 4, 2020
1 parent 37bf46d commit 021499a
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 224 deletions.
129 changes: 21 additions & 108 deletions src/catia.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-

# JACK Patchbay
# Copyright (C) 2010-2018 Filipe Coelho <falktx@falktx.com>
# Copyright (C) 2010-2020 Filipe Coelho <falktx@falktx.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
Expand Down Expand Up @@ -52,16 +52,11 @@
if not os.path.exists(os.path.join(iPATH, "aconnect")):
continue

from subprocess import getoutput
haveALSA = True

if sys.version_info >= (3, 0):
from subprocess import getoutput
else:
from commands import getoutput

if DEBUG:
print("Using experimental ALSA-MIDI support")

break

# ------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -172,15 +167,13 @@ def __init__(self, parent=None):
# -------------------------------------------------------------
# Check DBus

if haveDBus:
if gDBus.jack:
pass
else:
self.ui.act_tools_jack_start.setEnabled(False)
self.ui.act_tools_jack_stop.setEnabled(False)
self.ui.act_jack_configure.setEnabled(False)
self.ui.b_jack_configure.setEnabled(False)
# TODO remove
self.ui.act_tools_jack_start.setEnabled(False)
self.ui.act_tools_jack_stop.setEnabled(False)
self.ui.act_jack_configure.setEnabled(False)
self.ui.b_jack_configure.setEnabled(False)

if haveDBus:
if gDBus.a2j:
if gDBus.a2j.is_started():
self.a2jStarted()
Expand All @@ -194,10 +187,6 @@ def __init__(self, parent=None):

else:
# No DBus
self.ui.act_tools_jack_start.setEnabled(False)
self.ui.act_tools_jack_stop.setEnabled(False)
self.ui.act_jack_configure.setEnabled(False)
self.ui.b_jack_configure.setEnabled(False)
self.ui.act_tools_a2j_start.setEnabled(False)
self.ui.act_tools_a2j_stop.setEnabled(False)
self.ui.act_tools_a2j_export_hw.setEnabled(False)
Expand Down Expand Up @@ -239,7 +228,7 @@ def __init__(self, parent=None):
# -------------------------------------------------------------
# Set-up DBus

if gDBus.jack or gDBus.a2j:
if gDBus.a2j:
gDBus.bus.add_signal_receiver(self.DBusSignalReceiver, destination_keyword="dest", path_keyword="path",
member_keyword="member", interface_keyword="interface", sender_keyword="sender")

Expand Down Expand Up @@ -916,7 +905,7 @@ def jackStarted(self):
self.menuJackTransport(True)

self.ui.cb_buffer_size.setEnabled(True)
self.ui.cb_sample_rate.setEnabled(bool(gDBus.jack)) # DBus.jack and jacksettings.getSampleRate() != -1
self.ui.cb_sample_rate.setEnabled(False) # TODO remove
self.ui.menu_Jack_Buffer_Size.setEnabled(True)

self.ui.pb_dsp_load.setMaximum(100)
Expand All @@ -938,31 +927,9 @@ def jackStopped(self):
patchcanvas.clear()
self.initPorts()

if self.fNextSampleRate:
self.jack_setSampleRate(self.fNextSampleRate)

if gDBus.jack:
bufferSize = jacksettings.getBufferSize()
sampleRate = jacksettings.getSampleRate()
bufferSizeTest = bool(bufferSize != -1)
sampleRateTest = bool(sampleRate != -1)

if bufferSizeTest:
self.ui_setBufferSize(bufferSize)

if sampleRateTest:
self.ui_setSampleRate(sampleRate)

self.ui_setRealTime(jacksettings.isRealtime())

self.ui.cb_buffer_size.setEnabled(bufferSizeTest)
self.ui.cb_sample_rate.setEnabled(sampleRateTest)
self.ui.menu_Jack_Buffer_Size.setEnabled(bufferSizeTest)

else:
self.ui.cb_buffer_size.setEnabled(False)
self.ui.cb_sample_rate.setEnabled(False)
self.ui.menu_Jack_Buffer_Size.setEnabled(False)
self.ui.cb_buffer_size.setEnabled(False)
self.ui.cb_sample_rate.setEnabled(False)
self.ui.menu_Jack_Buffer_Size.setEnabled(False)

self.menuJackServer(False)
self.menuJackTransport(False)
Expand All @@ -985,12 +952,6 @@ def a2jStarted(self):
def a2jStopped(self):
self.menuA2JBridge(False)

def menuJackServer(self, started):
if gDBus.jack:
self.ui.act_tools_jack_start.setEnabled(not started)
self.ui.act_tools_jack_stop.setEnabled(started)
self.menuA2JBridge(False)

def menuJackTransport(self, enabled):
self.ui.act_transport_play.setEnabled(enabled)
self.ui.act_transport_stop.setEnabled(enabled)
Expand All @@ -1000,14 +961,14 @@ def menuJackTransport(self, enabled):
self.ui.group_transport.setEnabled(enabled)

def menuA2JBridge(self, started):
if gDBus.jack and not gDBus.jack.IsStarted():
self.ui.act_tools_a2j_start.setEnabled(False)
self.ui.act_tools_a2j_stop.setEnabled(False)
self.ui.act_tools_a2j_export_hw.setEnabled(bool(gDBus.a2j) and not gDBus.a2j.is_started())
else:
if gJack.client:
self.ui.act_tools_a2j_start.setEnabled(not started)
self.ui.act_tools_a2j_stop.setEnabled(started)
self.ui.act_tools_a2j_export_hw.setEnabled(not started)
else:
self.ui.act_tools_a2j_start.setEnabled(False)
self.ui.act_tools_a2j_stop.setEnabled(False)
self.ui.act_tools_a2j_export_hw.setEnabled(bool(gDBus.a2j) and not gDBus.a2j.is_started())

def DBusSignalReceiver(self, *args, **kwds):
if kwds["interface"] == "org.freedesktop.DBus" and kwds["path"] == "/org/freedesktop/DBus" and kwds["member"] == "NameOwnerChanged":
Expand All @@ -1033,13 +994,6 @@ def DBusSignalReceiver(self, *args, **kwds):

def DBusReconnect(self):
global gA2JClientName

try:
gDBus.jack = gDBus.bus.get_object("org.jackaudio.service", "/org/jackaudio/Controller")
jacksettings.initBus(gDBus.bus)
except:
gDBus.jack = None

try:
gDBus.a2j = dbus.Interface(gDBus.bus.get_object("org.gna.home.a2jmidid", "/"), "org.gna.home.a2jmidid.control")
gA2JClientName = str(gDBus.a2j.get_jack_client_name())
Expand Down Expand Up @@ -1110,24 +1064,6 @@ def slot_showAlsaMIDI(self, yesNo):
patchcanvas.clear()
self.initPorts()

@pyqtSlot()
def slot_JackServerStart(self):
ret = False
if gDBus.jack:
try:
ret = bool(gDBus.jack.StartServer())
except:
QMessageBox.warning(self, self.tr("Warning"), self.tr("Failed to start JACK, please check the logs for more information."))
#self.jackStopped()
return ret

@pyqtSlot()
def slot_JackServerStop(self):
ret = False
if gDBus.jack:
ret = bool(gDBus.jack.StopServer())
return ret

@pyqtSlot()
def slot_JackClearXruns(self):
if gJack.client:
Expand Down Expand Up @@ -1258,15 +1194,6 @@ def slot_handleCrash_a2j(self):
def slot_handleCrash_jack(self):
self.DBusReconnect()

if gDBus.jack:
self.ui.act_jack_configure.setEnabled(True)
self.ui.b_jack_configure.setEnabled(True)
else:
self.ui.act_tools_jack_start.setEnabled(False)
self.ui.act_tools_jack_stop.setEnabled(False)
self.ui.act_jack_configure.setEnabled(False)
self.ui.b_jack_configure.setEnabled(False)

if gDBus.a2j:
if gDBus.a2j.is_started():
self.a2jStarted()
Expand Down Expand Up @@ -1388,32 +1315,18 @@ def closeEvent(self, event):
gDBus.loop = DBusQtMainLoop(set_as_default=True)
gDBus.bus = dbus.SessionBus(mainloop=gDBus.loop)

try:
gDBus.jack = gDBus.bus.get_object("org.jackaudio.service", "/org/jackaudio/Controller")
jacksettings.initBus(gDBus.bus)
except:
gDBus.jack = None

try:
gDBus.a2j = dbus.Interface(gDBus.bus.get_object("org.gna.home.a2jmidid", "/"), "org.gna.home.a2jmidid.control")
gA2JClientName = str(gDBus.a2j.get_jack_client_name())
except:
gDBus.a2j = None
gA2JClientName = None

if DEBUG and (gDBus.jack or gDBus.a2j):
string = "Using DBus for "
if gDBus.jack:
string += "JACK"
if gDBus.a2j:
string += " and a2jmidid"
elif gDBus.a2j:
string += "a2jmidid"
print(string)
if DEBUG and gDBus.a2j:
print("Using DBus for a2jmidid")

else:
gDBus.jack = None
gDBus.a2j = None
gDBus.a2j = None
gA2JClientName = None
if DEBUG:
print("Not using DBus")
Expand Down
51 changes: 0 additions & 51 deletions src/clickablelabel.py

This file was deleted.

26 changes: 8 additions & 18 deletions src/patchcanvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,14 @@
# For a full copy of the GNU General Public License see the GPL.txt file

# Imports (Global)
if True:
from PyQt5.QtCore import pyqtSignal, pyqtSlot, qDebug, qCritical, qFatal, qWarning, Qt, QObject
from PyQt5.QtCore import QAbstractAnimation, QLineF, QPointF, QRectF, QSizeF, QSettings, QTimer
from PyQt5.QtGui import QColor, QLinearGradient, QPen, QPolygonF, QPainter, QPainterPath
from PyQt5.QtGui import QCursor, QFont, QFontMetrics
from PyQt5.QtWidgets import QGraphicsScene, QGraphicsItem, QGraphicsLineItem, QGraphicsPathItem
from PyQt5.QtWidgets import QGraphicsColorizeEffect, QGraphicsDropShadowEffect
from PyQt5.QtWidgets import QInputDialog, QLineEdit, QMenu
from PyQt5.QtSvg import QGraphicsSvgItem, QSvgRenderer
else:
from PyQt4.QtCore import pyqtSignal, pyqtSlot, qDebug, qCritical, qFatal, qWarning, Qt, QObject
from PyQt4.QtCore import QAbstractAnimation, QLineF, QPointF, QRectF, QSizeF, QSettings, QTimer
from PyQt4.QtGui import QColor, QLinearGradient, QPen, QPolygonF, QPainter, QPainterPath
from PyQt4.QtGui import QCursor, QFont, QFontMetrics
from PyQt4.QtGui import QGraphicsScene, QGraphicsItem, QGraphicsLineItem, QGraphicsPathItem
from PyQt4.QtGui import QGraphicsColorizeEffect, QGraphicsDropShadowEffect
from PyQt4.QtGui import QInputDialog, QLineEdit, QMenu
from PyQt4.QtSvg import QGraphicsSvgItem, QSvgRenderer
from PyQt5.QtCore import pyqtSignal, pyqtSlot, qDebug, qCritical, qFatal, qWarning, Qt, QObject
from PyQt5.QtCore import QAbstractAnimation, QLineF, QPointF, QRectF, QSizeF, QSettings, QTimer
from PyQt5.QtGui import QColor, QLinearGradient, QPen, QPolygonF, QPainter, QPainterPath
from PyQt5.QtGui import QCursor, QFont, QFontMetrics
from PyQt5.QtWidgets import QGraphicsScene, QGraphicsItem, QGraphicsLineItem, QGraphicsPathItem
from PyQt5.QtWidgets import QGraphicsColorizeEffect, QGraphicsDropShadowEffect
from PyQt5.QtWidgets import QInputDialog, QLineEdit, QMenu
from PyQt5.QtSvg import QGraphicsSvgItem, QSvgRenderer

# Imports (Theme)
from patchcanvas_theme import *
Expand Down
8 changes: 2 additions & 6 deletions src/patchcanvas_theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,8 @@
# ------------------------------------------------------------------------------------------------------------
# Imports (Global)

if True:
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QColor, QFont, QPen, QPixmap
else:
from PyQt4.QtCore import Qt
from PyQt4.QtGui import QColor, QFont, QPen, QPixmap
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QColor, QFont, QPen, QPixmap

# ------------------------------------------------------------------------------------------------------------
# patchcanvas-theme.cpp
Expand Down
15 changes: 4 additions & 11 deletions src/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-

# Common/Shared code
# Copyright (C) 2010-2018 Filipe Coelho <falktx@falktx.com>
# Copyright (C) 2010-2020 Filipe Coelho <falktx@falktx.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
Expand All @@ -24,21 +24,14 @@
from codecs import open as codecopen
from unicodedata import normalize

if True:
from PyQt5.QtCore import pyqtSignal, qWarning
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QApplication, QFileDialog, QMessageBox
else:
from PyQt4.QtCore import pyqtSignal, qWarning
from PyQt4.QtGui import QIcon
from PyQt4.QtGui import QApplication, QFileDialog, QMessageBox
from PyQt5.QtCore import pyqtSignal, qWarning
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QApplication, QFileDialog, QMessageBox

# ------------------------------------------------------------------------------------------------------------
# Set Platform

if sys.platform == "darwin":
from PyQt5.QtGui import qt_mac_set_menubar_icons
qt_mac_set_menubar_icons(False)
HAIKU = False
LINUX = False
MACOS = True
Expand Down

0 comments on commit 021499a

Please sign in to comment.