[kupfer] Make sure kupfer --list-plugins works from console



commit f6c5a90495dce424497dd8f91c6efb5e8f815af9
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Thu Mar 3 01:23:38 2011 +0100

    Make sure kupfer --list-plugins works from console
    
    Remove some pieces from core/plugins.py so that --list-plugins works
    from console.
    
    Now we also check gtk display as early as possible so we quit early if
    not screen is found with GTK.

 kupfer/core/plugins.py |    7 ++++++-
 kupfer/main.py         |   18 ++++++++++++++----
 kupfer/ui/browser.py   |    3 ---
 3 files changed, 20 insertions(+), 8 deletions(-)
---
diff --git a/kupfer/core/plugins.py b/kupfer/core/plugins.py
index ef85149..6de86ba 100644
--- a/kupfer/core/plugins.py
+++ b/kupfer/core/plugins.py
@@ -3,8 +3,8 @@ import pkgutil
 import sys
 
 from kupfer import pretty, config
-from kupfer import icons
 from kupfer.core import settings
+# import kupfer.icons on demand later
 
 sources_attribute = "__kupfer_sources__"
 text_sources_attribute = "__kupfer_text_sources__"
@@ -334,8 +334,13 @@ def _loader_hook(modpath):
 	return loader
 
 PLUGIN_ICON_FILE = "icon-list"
+icons = None
 
 def _load_icons(plugin_name):
+	global icons
+	if icons is None:
+		from kupfer import icons
+
 	try:
 		loader = _staged_import(plugin_name, _loader_hook)
 	except ImportError, exc:
diff --git a/kupfer/main.py b/kupfer/main.py
index f605add..5c94e07 100644
--- a/kupfer/main.py
+++ b/kupfer/main.py
@@ -132,12 +132,24 @@ def _set_process_title():
 	else:
 		setproctitle.setproctitle("kupfer")
 
+def gtkmain(quiet):
+	import pygtk
+	pygtk.require('2.0')
+	import gtk
+
+	if not gtk.gdk.screen_get_default():
+		print >>sys.stderr, "No Screen Found, Exiting..."
+		sys.exit(1)
+
+	from kupfer.ui import browser
+	w = browser.WindowController()
+	w.main(quiet=quiet)
+
 def main():
 	# parse commandline before importing UI
 	cli_opts = get_options()
 	print_banner()
 
-	from kupfer.ui import browser
 	from kupfer import pretty
 
 	if _debug:
@@ -150,8 +162,6 @@ def main():
 	sys.excepthook = sys.__excepthook__
 	_set_process_title()
 
-	w = browser.WindowController()
-
 	quiet = ("--no-splash" in cli_opts)
-	w.main(quiet=quiet)
+	gtkmain(quiet)
 
diff --git a/kupfer/ui/browser.py b/kupfer/ui/browser.py
index 252ded3..e562a51 100644
--- a/kupfer/ui/browser.py
+++ b/kupfer/ui/browser.py
@@ -6,9 +6,6 @@ import signal
 import sys
 import time
 
-import pygtk
-pygtk.require('2.0')
-
 try:
 	import appindicator
 except ImportError:



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]