[kupfer: 4/24] plugins: +vinagre - Plugin for Vinagre - Remote Desktop Viewer
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [kupfer: 4/24] plugins: +vinagre - Plugin for Vinagre - Remote Desktop Viewer
- Date: Fri, 27 Nov 2009 13:38:51 +0000 (UTC)
commit 83202432af74d1dcc643fa41385d998d5803731d
Author: Karol BÄ?dkowski <karol bedkowsk+gh gmail com>
Date: Sun Nov 15 17:14:46 2009 +0100
plugins: +vinagre - Plugin for Vinagre - Remote Desktop Viewer
Add:
- load and open Vinagre bookmarks
- open urls ssh:// and vnc:// with Vinagre
kupfer/plugin/vinagre.py | 109 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 109 insertions(+), 0 deletions(-)
---
diff --git a/kupfer/plugin/vinagre.py b/kupfer/plugin/vinagre.py
new file mode 100644
index 0000000..43d1c77
--- /dev/null
+++ b/kupfer/plugin/vinagre.py
@@ -0,0 +1,109 @@
+# -*- coding: UTF-8 -*-
+from __future__ import with_statement
+
+import os
+import gio
+from xml.etree import ElementTree
+
+from kupfer.objects import Leaf, Action, Source, AppLeafContentMixin, UrlLeaf
+from kupfer.helplib import FilesystemWatchMixin, PicklingHelperMixin
+from kupfer import utils
+
+__kupfer_name__ = _("Vinagre")
+__kupfer_sources__ = ("SessionSource", )
+__kupfer_actions__ = ('VinagreStartSession', )
+__description__ = _("Vinagre Bookmarks and Actions")
+__version__ = "0.1"
+__author__ = "Karol BÄ?dkowski <karol bedkowski gmail com>"
+
+
+class Bookmark(Leaf):
+ def __init__(self, url, name):
+ Leaf.__init__(self, url, name)
+ self._description = url
+
+ def get_actions(self):
+ yield VinagreStartSession()
+
+ def get_description(self):
+ return self._description
+
+ def get_icon_name(self):
+ return "computer"
+
+
+class VinagreStartSession(Action):
+ def __init__(self):
+ Action.__init__(self, _('Start Vinagre Session'))
+
+ def activate(self, leaf):
+ utils.launch_commandline("vinagre %s" % leaf.object)
+
+ def get_icon_name(self):
+ return 'vinagre'
+
+ def item_types(self):
+ yield Bookmark
+ yield UrlLeaf
+
+ def valid_for_item(self, item):
+ if isinstance(item, Bookmark):
+ return True
+ elif isinstance(item, UrlLeaf):
+ return (item.object.startswith('ssh://') \
+ or item.object.startswith('vnc://'))
+
+ return False
+
+
+class SessionSource(AppLeafContentMixin, Source, PicklingHelperMixin,
+ FilesystemWatchMixin):
+ appleaf_content_id = 'vinagre'
+
+ def __init__(self, name=_("Vinagre Bookmarks")):
+ Source.__init__(self, name)
+ self.unpickle_finish()
+
+ def pickle_prepare(self):
+ self.monitor = None
+
+ def unpickle_finish(self):
+ self._bookmark_file = os.path.expanduser(
+ '~/.local/share/vinagre/vinagre-bookmarks.xml')
+ gfile = gio.File(self._bookmark_file)
+ self.monitor = gfile.monitor_file(gio.FILE_MONITOR_NONE, None)
+ if self.monitor:
+ self.monitor.connect("changed", self._on_bookmarks_changed)
+
+ def _on_bookmarks_changed(self, monitor, file1, file2, evt_type):
+ if evt_type in (gio.FILE_MONITOR_EVENT_CREATED,
+ gio.FILE_MONITOR_EVENT_DELETED,
+ gio.FILE_MONITOR_EVENT_CHANGED):
+ self.mark_for_update()
+
+ def get_items(self):
+ if not os.path.isfile(self._bookmark_file):
+ return
+
+ try:
+ tree = ElementTree.parse(self._bookmark_file)
+ for item in tree.findall('item'):
+ protocol = item.find('protocol').text
+ name = item.find('name').text
+ host = item.find('host').text
+ port = item.find('port').text
+ url = '%s://%s:%s' % (protocol, host, port)
+ yield Bookmark(url, name)
+ except StandardError, err:
+ self.output_error(err)
+
+ def get_description(self):
+ return None
+
+ def get_icon_name(self):
+ return "vinagre"
+
+ def provides(self):
+ yield Bookmark
+
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]