Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of git://github.com/jkz88/amsn2 into jkz88/master

  • Loading branch information...
commit 06465d5b9bf83a72ec190509555ccc8398c94aa0 2 parents ded759b + 3be51b9
@drf authored
Showing with 24 additions and 52 deletions.
  1. +24 −52 amsn2.py
View
76 amsn2.py 100755 → 100644
@@ -11,56 +11,29 @@
passwd = None
default_front_end = "console"
- if os.name == "posix":
- system = os.uname()[0]
- if system == "Linux":
-
- """ Here we are trying to import some base modules for the GUI
- interfaces to get a working default frontend. EFL is the first one,
- then come the others.
-
- Suggestion/TODO: we can avoid OS detection through this method.
- I think it makes more sense creating a priority list, something like
- that one:
-
- cocoa > efl > qt4 > gtk > console
-
- As you can imagine, the OS you're using no longer matters: IMHO
- this list (except for qt & gtk, didn't know what to put first) is
- the right way to do it, since it tries to be as native as possible.
- There are some even better ways to do it, especially on gtk/qt side.
- For example, we can use DBus to know what DE is running.
-
- So, my thoughts on how to do it:
- Try cocoa, try Efl. If both went bad, try to see if DBus is running.
- If not, we're probably not on Linux, so give priority to Qt. If it is,
- check for kded service or for a GNOME service and choose that toolkit.
- When all else fails, console will be our friend.
-
- This way we'll have the best default possible, and as you can see
- from the first implementation, it's really easy to do.
- """
-
- try:
- import ecore
- default_front_end = "efl"
- except ImportError: # Efl not available
- try:
- import PyQt4.QtGui
- default_front_end = "qt4"
- except ImportError: # Qt not available
- try:
- import gtk
- default_front_end = "gtk"
- except ImportError: # GTK not available
- print "No graphical toolkits detected, falling back to console..."
- default_front_end = "console"
-
- elif system == "Darwin":
- default_front_end = "cocoa"
- elif os.name == "nt":
- default_front_end = "qt4"
-
+ # Detect graphical toolkit available.
+ # Format - 'default_front_end : module name'
+ # cocoa > efl > qt4 > gtk > console
+ toolkits = {'cocoa' : '????',
+ 'elf' : 'ecore',
+ 'qt4' : 'PyQt4.QtGui',
+ 'gtk' : 'gtk',
+ 'console' : None}
+ for toolkit in toolkits:
+ try:
+ default_front_end = toolkit
+ module_name = toolkits[toolkit]
+ module = __import__(module_name)
+ vars()[module_name] = module
+ # Debug
+ # print 'Imported toolkit "%s" with module "%s"' % (toolkit, module)
+ break
+ except ImportError:
+ # Debug
+ # print 'Couldn\'t import %s - doesn\'t exist!' % module_name
+ pass
+ except TypeError:
+ pass
parser = optparse.OptionParser()
parser.add_option("-a", "--account", dest="account",
@@ -75,5 +48,4 @@
amsn = aMSNCore(options)
- amsn.run()
-
+ amsn.run()
Please sign in to comment.
Something went wrong with that request. Please try again.