summaryrefslogtreecommitdiff
path: root/CompizManager.py
diff options
context:
space:
mode:
Diffstat (limited to 'CompizManager.py')
-rwxr-xr-xCompizManager.py50
1 files changed, 28 insertions, 22 deletions
diff --git a/CompizManager.py b/CompizManager.py
index 24ce8b1..724b7bd 100755
--- a/CompizManager.py
+++ b/CompizManager.py
@@ -16,19 +16,20 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
#
-# Author: Kristian F. Erikson <kristian@erikson.dk>
+# Author: Kristian F. Erikson <kristian.erikson@eyemagnet.com>
#
-# I am still new to using python. So you find any code that's not 'good' python
-# please flick me an email so I can correct it :)
-
import dbus
-import xml.etree.ElementTree
+import ElementTree
import time
from CompizPlugin import CompizPlugin # Import the local modules
from CompizConnection import CompizConnection
from CompizTools import *
+from CompizTests import *
+
+pluginXmlLocation = "./plugins.xml"
+#pluginXmlLocation = "/home/apps/eyemagnet/eyemagnet_compiz_manager/plugins.xml"
class CompizManager(object):
"""
@@ -36,7 +37,7 @@ class CompizManager(object):
Compiz Plugins can be managed interactively in Python using this module.
"""
- def __init__(self):
+ def __init__(self, quickBuild = True):
""" Build a compiz manager instance. """
self.connection = CompizConnection()
self.pluginDict = {}
@@ -44,6 +45,7 @@ class CompizManager(object):
self.activePluginList = []
self.active = False
self.connect()
+ self.quickBuild = quickBuild
self.buildPlugins()
def connect(self): # Connects to compiz and gets the list of plugins
@@ -59,7 +61,7 @@ class CompizManager(object):
def buildPlugins(self): # Creates new plugin objects for each of the plugins
""" Internal function that builds the plugins and their options and actions. """
- tree = xml.etree.ElementTree.parse("plugins.xml") # Builds even is Compiz not running
+ tree = ElementTree.parse(pluginXmlLocation) # Builds even is Compiz not running
for pluginName in self.pluginNameList:
plugin = CompizPlugin(pluginName, self)
actionsAndArgs = tree.find(pluginName)
@@ -68,8 +70,13 @@ class CompizManager(object):
def getPlugin(self, pluginName): # Returns specified plugin object (if active)
""" Returns a representation of a Compiz plugin, if Compiz is running. """
- if self.active: return self.pluginDict[pluginName]
+ if self.active:
+ if self.quickBuild:
+ self.pluginDict[pluginName].update()
+ return self.pluginDict[pluginName]
else: raise CompizNotActiveError
+ # Needs new logic so we can still send things even if plugin not loaded
+
def listActivePlugins(self): # List all currently active plugins
""" Returns a list of currently active Compiz plugins. """
@@ -176,8 +183,11 @@ class CompizManager(object):
# Go get the list of windows from the now C extension written specifically
# Implementation using wmctrl source code
- return CompizPyWindowList.listWindows()
-
+ returnedList = CompizPyWindowList.listWindows()
+ # Decode unicode chars correctly first:
+ for window in returnedList:
+ window['title'] = window['title'].decode('utf-8')
+ return returnedList
def AllToScreen():
""" Prints all Plugins with their actions and options to the screen. """
@@ -187,10 +197,10 @@ def AllToScreen():
print("Plugin: " + str(tempPlugin.name) + ' active=' + str(tempPlugin.active))
print("Options:\n" + str(tempPlugin.listOptions()))
print("Actions:\n" + str(tempPlugin.listActions()) + '\n')
-
def AllToFile(fileName):
""" Prints all Plugins with their actions and options to a file. """
+ manager = CompizManager()
listofPlugins = manager.listAllPlugins()
output = open(fileName, 'w')
for plugin in listofPlugins:
@@ -198,13 +208,10 @@ def AllToFile(fileName):
output.write("Plugin: " + str(tempPlugin.name) + ' active=' + str(tempPlugin.active) + '\n')
output.write("Options:\n" + str(tempPlugin.listOptions()) + '\n')
output.write("Actions:\n" + str(tempPlugin.listActions()) + '\n\n')
-
-if __name__ == '__main__':
- # Set a global manager for the tests:
- manager = CompizManager()
-
- from CompizTests import *
+def RunTests():
+ """ Simple function to launch testing of this module """
+ manager = CompizManager()
# Pre test setup
preTestSetup()
# Run the tests
@@ -212,10 +219,9 @@ if __name__ == '__main__':
unittest.TextTestRunner(verbosity=2).run(suite)
# Run the post test cleanup
postTestCleanup()
+
+if __name__ == '__main__':
+ RunTests() # Run the tests
+ AllToFile('Plugins with options and actions.txt') # Print a file with actions and options listed in it
- # Print a file with actions and options listed in it
- AllToFile('Plugins with options and actions.txt')
-
- print "\nWindows currently active:"
- print manager.listWindows()