Skip to content

Commit

Permalink
Check wnck python module existence
Browse files Browse the repository at this point in the history
  • Loading branch information
nagappan committed Mar 13, 2012
1 parent 36a9ee0 commit ab02bc0
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
24 changes: 22 additions & 2 deletions ldtpd/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,24 @@
Headers in this file shall remain intact.
"""

wnckModule = False
from pyatspi import findDescendant, Registry
import locale
import subprocess
try:
# If we have gtk3+ gobject introspection, use that
from gi.repository import Wnck as wnck
from gi.repository import Gtk as gtk
gtk3 = True
wnckModule = gtk3 = True
except:
# No gobject introspection, use gtk2 libwnck
import gtk
import wnck
try:
import wnck
wnckModule = True
except:
# Not all environments support wnck package
pass
gtk3 = False
from utils import Utils, ProcessStats
from constants import abbreviated_roles
Expand Down Expand Up @@ -533,6 +539,8 @@ def maximizewindow(self, window_name = None):
@return: 1 if window maximized, 0 if not.
@rtype: integer
"""
if not wnckModule:
raise LdtpServerException('Install python wnck module')
waiter = MaximizeWindow(window_name)

return int(waiter.run())
Expand All @@ -548,6 +556,8 @@ def minimizewindow(self, window_name = None):
@return: 1 if window minimized, 0 if not.
@rtype: integer
"""
if not wnckModule:
raise LdtpServerException('Install python wnck module')
waiter = MinimizeWindow(window_name)

return int(waiter.run())
Expand All @@ -563,6 +573,8 @@ def unmaximizewindow(self, window_name = None):
@return: 1 if window unmaximized, 0 if not.
@rtype: integer
"""
if not wnckModule:
raise LdtpServerException('Install python wnck module')
waiter = UnmaximizeWindow(window_name)

return int(waiter.run())
Expand All @@ -578,6 +590,8 @@ def unminimizewindow(self, window_name = None):
@return: 1 if window unminimized, 0 if not.
@rtype: integer
"""
if not wnckModule:
raise LdtpServerException('Install python wnck module')
waiter = UnminimizeWindow(window_name)

return int(waiter.run())
Expand All @@ -593,6 +607,8 @@ def activatewindow(self, window_name):
@return: 1 if window unminimized, 0 if not.
@rtype: integer
"""
if not wnckModule:
raise LdtpServerException('Install python wnck module')
waiter = ActivateWindow(window_name)

return int(waiter.run())
Expand All @@ -608,6 +624,8 @@ def closewindow(self, window_name = None):
@return: 1 if window unminimized, 0 if not.
@rtype: integer
"""
if not wnckModule:
raise LdtpServerException('Install python wnck module')
waiter = CloseWindow(window_name)

return int(waiter.run())
Expand Down Expand Up @@ -1300,6 +1318,8 @@ def getobjectnameatcoords(self, wait_time = 0.0):
matching name and type as list of string [objectname]
@rtype: (string, list)
"""
if not wnckModule:
raise LdtpServerException('Install python wnck module')
self.wait(wait_time)
# Following lines from Accerciser, _inspectUnderMouse method
# quick_select.py file
Expand Down
12 changes: 9 additions & 3 deletions ldtpd/waiters.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
Headers in this file shall remain intact.
"""

wnckModule = False
from utils import Utils
import re
import time
Expand All @@ -27,13 +28,18 @@
from gi.repository import Wnck as wnck
from gi.repository import Gtk as gtk
from gi.repository import GObject as gobject
gtk3 = True
wnckModule = gtk3 = True
except:
# No gobject introspection, use gtk2 libwnck
gtk3 = False
import gtk
import wnck
import gobject
gtk3 = False
try:
import wnck
wnckModule = True
except:
# Not all environments support wnck package
pass
import fnmatch
import pyatspi
import traceback
Expand Down

0 comments on commit ab02bc0

Please sign in to comment.