[kupfer] plugin.core: Add (debug) runnable item Restart Kupfer



commit bdeda07e5e0d20a7f5a68a94f603090c1a1087f5
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Wed Oct 28 22:24:29 2009 +0100

    plugin.core: Add (debug) runnable item Restart Kupfer
    
    Re-exec kupfer, but only show this item when debug is enabled. We can
    allow it for normal use later if it proves to work in normal
    situations.

 kupfer/plugin/core.py |   32 +++++++++++++++++++++++++++-----
 1 files changed, 27 insertions(+), 5 deletions(-)
---
diff --git a/kupfer/plugin/core.py b/kupfer/plugin/core.py
index be61248..e29bc8c 100644
--- a/kupfer/plugin/core.py
+++ b/kupfer/plugin/core.py
@@ -143,6 +143,27 @@ class DebugInfo (Action, pretty.OutputMixin):
 		if pretty.debug:
 			yield Leaf
 
+class DebugRestart (RunnableLeaf):
+	def __init__(self):
+		RunnableLeaf.__init__(self, None, u"Restart Kupfer")
+
+	@classmethod
+	def _exec_new_kupfer(cls):
+		import os
+		os.execvp("kupfer", ("kupfer", "--debug", ))
+
+	def run(self):
+		import atexit
+		import sys
+
+		gtk.main_quit()
+		atexit.register(self._exec_new_kupfer)
+
+	def get_description(self):
+		return u"Restart Kupfer quickly (for internal kupfer use)"
+	def get_icon_name(self):
+		return gtk.STOCK_REFRESH
+
 class Quit (RunnableLeaf):
 	qf_id = "quit"
 	def __init__(self, name=None):
@@ -186,11 +207,12 @@ class KupferSource (AppLeafContentMixin, Source):
 	def is_dynamic(self):
 		return True
 	def get_items(self):
-		return (
-			About(),
-			Preferences(),
-			Quit(),
-		)
+		yield About()
+		yield Preferences()
+		yield Quit()
+		if pretty.debug:
+			yield DebugRestart()
+
 	def get_description(self):
 		return _("Kupfer items and actions")
 	def get_icon_name(self):



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