[kupfer] Add gnome-terminal plugin



commit a912e1a7f2bbffaa2a02cfe7e2f425da55624d2c
Author: Chmouel Boudjnah <chmouel boudjnah rackspace co uk>
Date:   Sun Nov 22 02:09:44 2009 +0000

    Add gnome-terminal plugin
    
    A gnome-terminal plugin which allow to launch saved sessions.

 kupfer/plugin/gnome-terminal.py |   61 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 61 insertions(+), 0 deletions(-)
---
diff --git a/kupfer/plugin/gnome-terminal.py b/kupfer/plugin/gnome-terminal.py
new file mode 100644
index 0000000..2bc0b67
--- /dev/null
+++ b/kupfer/plugin/gnome-terminal.py
@@ -0,0 +1,61 @@
+import os
+
+from kupfer.objects import Source, Leaf, Action, \
+    AppLeafContentMixin, PicklingHelperMixin
+from kupfer import utils, icons
+
+__kupfer_name__ = _("Gnome Terminal Sessions")
+__kupfer_sources__ = ("SessionsSource", )
+__description__ = _("Launch Gnome Terminal Session")
+__version__ = ""
+__author__ = "Chmouel Boudjnah <chmouel chmouel com>"
+
+import gconf
+
+GCONF_KEY = "/apps/gnome-terminal/profiles"
+
+
+class Terminal(Leaf):
+	""" Leaf represent session saved in Gnome Terminal"""
+
+	def __init__(self, name):
+		Leaf.__init__(self, name, name)
+
+	def get_actions(self):
+		yield OpenSession()
+
+	def get_icon_name(self):
+		return "terminal"
+
+
+class OpenSession(Action):
+	""" Opens Gnome Terminal session """
+
+	def activate(self, leaf):
+		utils.spawn_async(["gnome-terminal",
+				   "--profile=%s" % leaf.object],
+				  in_dir=os.path.expanduser("~"))
+
+	def get_gicon(self):
+		return icons.ComposedIcon("gtk-execute", "terminal")
+
+
+class SessionsSource(AppLeafContentMixin, Source, PicklingHelperMixin):
+	""" Yield Gnome Terminal profiles """
+	appleaf_content_id = 'gnome-terminal'
+
+	def __init__(self):
+		Source.__init__(self, name=_("Launch Gnome Terminal session"))
+
+	def get_items(self):
+		gc = gconf.client_get_default()
+		if not gc.dir_exists(GCONF_KEY):
+			return
+
+		for entry in gc.all_dirs(GCONF_KEY):
+			yield Terminal(gc.get_string("%s/visible_name" % entry))
+
+# Local Variables: ***
+# python-indent: 8 ***
+# indent-tabs-mode: t ***
+# End: ***



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