fixes needed for a os x version
This commit is contained in:
parent
dbad342cbc
commit
dd15d2b44f
158 changed files with 96 additions and 12556 deletions
|
|
@ -2,9 +2,11 @@
|
|||
|
||||
import os, sys, pickle, subprocess, shutil, json
|
||||
from PyQt4 import QtCore, QtGui, QtWebKit, QtNetwork
|
||||
from sys import platform as _platform
|
||||
|
||||
RUNNING_LOCAL = os.path.basename(sys.argv[0]) == "Bungloo.py"
|
||||
RUNNING_ON_WINDOWS = os.name == "nt"
|
||||
RUNNING_ON_OSX = _platform == "darwin"
|
||||
|
||||
if RUNNING_LOCAL or RUNNING_ON_WINDOWS:
|
||||
import Windows, Helper, SingleApplication
|
||||
|
|
@ -33,7 +35,7 @@ class Bungloo():
|
|||
self.authentification_succeded()
|
||||
|
||||
def resources_path(self):
|
||||
if RUNNING_LOCAL:
|
||||
if RUNNING_LOCAL and not RUNNING_ON_OSX:
|
||||
return os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '..'))
|
||||
else:
|
||||
return Helper.Helper.get_resource_path()
|
||||
|
|
@ -95,6 +97,7 @@ class Bungloo():
|
|||
def handleMessage(self, args):
|
||||
# argv is just a array of words which you can get in from the outside
|
||||
argv = json.loads(str(args))
|
||||
print args
|
||||
if len(argv) > 0:
|
||||
if argv[0] == "--new-message":
|
||||
text = " ".join(argv[1:])
|
||||
|
|
@ -308,10 +311,10 @@ if __name__ == "__main__":
|
|||
if len(sys.argv) > 1 and sys.argv[1] == "--help":
|
||||
print """
|
||||
Usage: bungloo [option [text]]
|
||||
|
||||
Options:
|
||||
--new-message [text] Opens new message window with text
|
||||
--search text Opens search with text
|
||||
|
||||
Options:
|
||||
--new-message [text] Opens new message window with text
|
||||
--search text Opens search with text
|
||||
"""
|
||||
sys.exit(1)
|
||||
|
||||
|
|
@ -330,7 +333,7 @@ Usage: bungloo [option [text]]
|
|||
app.sendMessage(json.dumps(sys.argv[1:]))
|
||||
sys.exit(1)
|
||||
|
||||
bungloo = Bungloo()
|
||||
app.connect(app, QtCore.SIGNAL('messageAvailable'), bungloo.handleMessage)
|
||||
app.bungloo = Bungloo()
|
||||
app.connect(app, QtCore.SIGNAL('messageAvailable'), app.bungloo.handleMessage)
|
||||
|
||||
sys.exit(app.exec_())
|
||||
|
|
|
|||
14
Qt/Helper.py
14
Qt/Helper.py
|
|
@ -4,17 +4,21 @@ from PyQt4.QtCore import QTimer, QVariant, SIGNAL
|
|||
from PyQt4.QtGui import *
|
||||
from PyQt4.QtNetwork import QNetworkAccessManager, QNetworkRequest, QNetworkReply, QSslSocket
|
||||
from PyQt4.QtWebKit import QWebView
|
||||
from sys import platform as _platform
|
||||
|
||||
import os, sys
|
||||
|
||||
import array
|
||||
|
||||
class Helper:
|
||||
@classmethod
|
||||
def get_resource_path(cls):
|
||||
if os.name == "nt":
|
||||
@classmethod
|
||||
def get_resource_path(cls):
|
||||
|
||||
if os.name == "nt":
|
||||
return os.path.dirname(sys.argv[0])
|
||||
else:
|
||||
elif _platform == "darwin":
|
||||
return os.path.dirname(sys.argv[0])
|
||||
else:
|
||||
return os.path.dirname(__file__)
|
||||
|
||||
class WebPage(QtWebKit.QWebPage):
|
||||
|
|
@ -93,6 +97,8 @@ class WebViewCreator(QtWebKit.QWebView):
|
|||
os_type = "linux"
|
||||
if os.name == "nt":
|
||||
os_type = "windows"
|
||||
elif _platform == "darwin":
|
||||
os_type = "osx"
|
||||
frame.evaluateJavaScript("var OS_TYPE = '" + os_type + "';")
|
||||
|
||||
js_plugin_path = os.path.expanduser('~/.config/bungloo/Plugin.js')
|
||||
|
|
|
|||
|
|
@ -3,9 +3,11 @@
|
|||
# from http://stackoverflow.com/questions/8786136/pyqt-how-to-detect-and-close-ui-if-its-already-running
|
||||
|
||||
from PyQt4 import QtGui, QtCore, QtNetwork
|
||||
import json
|
||||
|
||||
class SingleApplication(QtGui.QApplication):
|
||||
def __init__(self, argv, key):
|
||||
self.bungloo = None
|
||||
QtGui.QApplication.__init__(self, argv)
|
||||
self._memory = QtCore.QSharedMemory(self)
|
||||
self._memory.setKey(key)
|
||||
|
|
@ -54,6 +56,13 @@ class SingleApplicationWithMessaging(SingleApplication):
|
|||
return True
|
||||
return False
|
||||
|
||||
def event(self, event):
|
||||
if isinstance(event, QtGui.QFileOpenEvent):
|
||||
url = str(event.url().toString())
|
||||
args = json.dumps([url])
|
||||
self.bungloo.handleMessage(args)
|
||||
return True
|
||||
|
||||
class Window(QtGui.QWidget):
|
||||
def __init__(self):
|
||||
QtGui.QWidget.__init__(self)
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ class Preferences:
|
|||
|
||||
# image view
|
||||
image = QtGui.QPixmap(self.app.resources_path() + "/images/Icon.png")
|
||||
print self.app.resources_path() + "/images/Icon.png"
|
||||
image_view = QtGui.QLabel(self.window)
|
||||
image_view.setGeometry(20, 20, 146, 146)
|
||||
image_view.setPixmap(image)
|
||||
|
|
|
|||
Reference in a new issue