/usr/share/cinnamon/cinnamon-looking-glass/lookingglass_proxy.py is in cinnamon-common 3.6.7-8ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | import dbus
from gi.repository import Gio
LG_DBUS_NAME = "org.Cinnamon.LookingGlass"
LG_DBUS_PATH = "/org/Cinnamon/LookingGlass"
class LookingGlassProxy:
def __init__(self):
self._signals = []
self._statusChangeCallbacks = []
self._proxy = None
Gio.bus_watch_name(Gio.BusType.SESSION, LG_DBUS_NAME, Gio.BusNameWatcherFlags.NONE, self._onConnect, self._onDisconnect)
def addStatusChangeCallback(self, callback):
self._statusChangeCallbacks.append(callback)
def refreshStatus(self):
if self._proxy is not None:
self._setStatus(True)
else:
self._setStatus(False)
def getIsReady(self):
return self._proxy is not None
def connect(self, name, callback):
self._signals.append((name, callback))
def _onSignal(self, proxy, sender_name, signal_name, params):
for name, callback in self._signals:
if signal_name == name:
callback(*params)
def _setStatus(self, state):
for callback in self._statusChangeCallbacks:
callback(state)
def _onConnect(self, connection, name, owner):
if self._proxy:
return
self._initProxy()
def _onDisconnect(self, connection, name):
self._proxy = None
self._setStatus(False)
def _initProxy(self):
try:
self._proxy = Gio.DBusProxy.new_for_bus(Gio.BusType.SESSION, Gio.DBusProxyFlags.NONE, None,
LG_DBUS_NAME, LG_DBUS_PATH, LG_DBUS_NAME, None, self._onProxyReady, None)
except dbus.exceptions.DBusException as e:
print(e)
self._proxy = None
def _onProxyReady(self, object, result, data=None):
self._proxy = Gio.DBusProxy.new_for_bus_finish(result)
self._proxy.connect("g-signal", self._onSignal)
self._setStatus(True)
# Proxy Methods:
def Eval(self, code):
if self._proxy:
try:
self._proxy.Eval('(s)', code)
except Exception:
pass
def GetResults(self):
if self._proxy:
try:
return self._proxy.GetResults('()')
except Exception:
pass
return (False, "")
def AddResult(self, code):
if self._proxy:
try:
self._proxy.AddResult('(s)', code)
except Exception:
pass
def GetErrorStack(self):
if self._proxy:
try:
return self._proxy.GetErrorStack('()')
except Exception:
pass
return (False, "")
def GetMemoryInfo(self):
if self._proxy:
try:
return self._proxy.GetMemoryInfo('()')
except Exception:
pass
return (False, 0, {})
def FullGc(self):
if self._proxy:
try:
self._proxy.FullGc('()')
except Exception:
pass
def Inspect(self, code):
if self._proxy:
try:
return self._proxy.Inspect('(s)', code)
except Exception:
pass
return (False, "")
def GetLatestWindowList(self):
if self._proxy:
try:
return self._proxy.GetLatestWindowList('()')
except Exception:
pass
return (False, "")
def StartInspector(self):
if self._proxy:
try:
self._proxy.StartInspector('()')
except Exception:
pass
def GetExtensionList(self):
if self._proxy:
try:
return self._proxy.GetExtensionList('()')
except Exception:
pass
return (False, "")
def ReloadExtension(self, uuid, xletType):
if self._proxy:
try:
return self._proxy.ReloadExtension('(ss)', uuid, xletType)
except Exception:
pass
return (False, "")
|