Browse files

Added search plugin

  • Loading branch information...
1 parent cf5f8a0 commit 9fafb5c57c9ee7a8af0e49a97921e1ce4026de3c John Cooper committed Nov 23, 2010
Showing with 38 additions and 0 deletions.
  1. +6 −0 README
  2. +32 −0 searchplugin.py
View
6 README
@@ -0,0 +1,6 @@
+Some plugins for terminator
+
+Put them in ~/.config/terminator/plugins/
+
+Online Search: searchplugin.py
+ Search google for the selected text in a terminal
View
32 searchplugin.py
@@ -0,0 +1,32 @@
+import gtk
+import urllib
+import terminatorlib.plugin as plugin
+
+
+# available must contain a list of all the classes that you want exposed
+available = ['SearchPlugin']
+
+class SearchPlugin(plugin.Plugin):
+ capabilities = ['terminal_menu']
+
+ def _search(self, searchMenu):
+ """Launch google search for string"""
+ search = "http://google.co.uk/search?hl=en&q=%s&meta="
+ clip = gtk.clipboard_get(gtk.gdk.SELECTION_PRIMARY)
+ searchstring = clip.wait_for_text()
+ uri = search % urllib.quote(searchstring.encode("utf-8"))
+ gtk.show_uri(None, uri, gtk.gdk.CURRENT_TIME)
+
+
+
+ def callback(self, menuitems, menu, terminal):
+ """Add our menu items to the menu"""
+ self.terminal = terminal
+ item = gtk.ImageMenuItem(gtk.STOCK_FIND)
+ item.set_label("Search Online")
+ item.connect('activate', self._search)
+ item.set_sensitive(terminal.vte.get_has_selection())
+ menuitems.append(item)
+
+
+

0 comments on commit 9fafb5c

Please sign in to comment.