summaryrefslogtreecommitdiff
path: root/CompizPlugin.py
diff options
context:
space:
mode:
Diffstat (limited to 'CompizPlugin.py')
-rwxr-xr-xCompizPlugin.py66
1 files changed, 50 insertions, 16 deletions
diff --git a/CompizPlugin.py b/CompizPlugin.py
index ca36d14..c36f1fe 100755
--- a/CompizPlugin.py
+++ b/CompizPlugin.py
@@ -16,7 +16,7 @@
# 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>
#
import dbus
@@ -52,18 +52,25 @@ class CompizPlugin(object):
self.options = {}
self.actions = {}
self.active = False
- self.update()
+ if not self.manager.quickBuild:
+ self.update()
def listOptions(self):
""" Returns a list of available options for the plugin """
- if self.active: # Only return options if we're active
+ if not self.active:
+ if self.manager.quickBuild:
+ self.update()
+ if self.active: # Only return options if we're active
return self.options
else:
return {}
def listActions(self):
""" Returns a list of available actions for the plugin """
- if self.active: # Only return actions if we're active
+ if not self.active:
+ if self.manager.quickBuild:
+ self.update()
+ if self.active: # Only return actions if we're active
return self.actions
else:
return {}
@@ -168,6 +175,7 @@ class CompizPlugin(object):
inActions = actionsXML.getchildren()
for action in inActions:
+
if action.getchildren():
self.actions[action.tag] = {}
for subaction in action.getchildren():
@@ -177,6 +185,9 @@ class CompizPlugin(object):
def setOption(self, optionName, newOptionValue):
""" Sets the value of an option. Refer to listOptions() to determine what the type of value is for an option. """
+ if not self.active:
+ if self.manager.quickBuild:
+ self.update()
if self.active:
if optionName in self.options:
locationString = ''
@@ -208,6 +219,9 @@ class CompizPlugin(object):
def getOption(self, optionName):
""" Returns value associated with the option """
+ if not self.active:
+ if self.manager.quickBuild:
+ self.update()
if self.active:
if optionName in self.options:
locationString = ''
@@ -231,20 +245,20 @@ class CompizPlugin(object):
raise CompizPluginNotActiveError # Raise exception if plugin is not active
def doAction(self, action, arguments = ''): # Takes the name of the action and the arguments in a dict
+ if not self.active:
+ if self.manager.quickBuild:
+ self.update()
""" Calls an action. Some actions require arguments which then must be specified.
If arguments are required can be determined by examining the output of listActions(). """
if self.active:
if action in self.actions:
paramsString = []
-
# Attach root window whenever making a method call
paramsString.append(unicode('root'))
xwininfo = os.popen("xwininfo -root | grep id: | awk '{ print $4 }'")
xwininfoOutput = xwininfo.read()
paramsString.append(int(xwininfoOutput, 16))
-
advancedMethod = False
-
try:
for param in self.actions[action]:
if type(self.actions[action][param]) == type({}):
@@ -253,15 +267,35 @@ class CompizPlugin(object):
# First attach name of parameter
paramsString.append(unicode(param))
if param == 'window': # If param is a window title find id for us
- if self.actions[action][param] == type(arguments[param]): # Check parameters are correct type
- xwininfo = os.popen("xwininfo -name '" + arguments[param] + "' | grep id: | awk '{ print $4 }'")
- xwininfoOutput = xwininfo.read()
- try:
- paramsString.append(int(xwininfoOutput, 16))
- except ValueError:
- raise CompizPluginWindowNotFoundError # If window not found raise exception
- else:
- raise CompizPluginTypeArgError
+ try: # First try see if we're given the id directly
+ if self.actions[action][param] == type(int(arguments['windowid'])): # Check parameters are correct type
+ # paramsString.append(arguments['windowid'])
+ # First check if window exist
+ windowList = self.manager.listWindows() # Use window manager to find id
+ windowFound = False
+ for window in windowList:
+ if window['id'] == arguments['windowid']:
+ paramsString.append(window['id'])
+ windowFound = True
+ if not windowFound:
+ raise CompizPluginWindowNotFoundError # Notify user if window not found
+ else:
+ raise CompizPluginTypeArgError
+ except KeyError: # Now see if we're given the window title
+ try:
+ if type(arguments['windowtitle']) == ( type('hello') or type(u'hello') ): # Check title is a string
+ windowList = self.manager.listWindows() # Use window manager to find id
+ windowFound = False
+ for window in windowList:
+ if window['title'] == unicode(arguments['windowtitle']):
+ paramsString.append(window['id'])
+ windowFound = True
+ if not windowFound:
+ raise CompizPluginWindowNotFoundError # Notify user if window not found
+ else:
+ raise CompizPluginTypeArgError
+ except KeyError:
+ raise CompizPluginTypeArgError
else: # Otherwise go ahead and attach the parameter
if self.actions[action][param] == type(arguments[param]): # Check parameters are correct type
paramsString.append(arguments[param])