Web search right-click for note editor

svn: r15820
This commit is contained in:
Doug Blank 2010-08-26 14:00:27 +00:00
parent 5b975f93cc
commit 3c151885ee
2 changed files with 19 additions and 0 deletions

View File

@ -148,6 +148,7 @@ register('behavior.startup', 0)
register('behavior.surname-guessing', 0)
register('behavior.use-tips', False)
register('behavior.welcome', 100)
register('behavior.web-search-url', 'http://google.com/#&q=%(text)s')
register('export.proxy-order', [
["privacy", 0],

View File

@ -58,6 +58,7 @@ from gui.widgets.toolcomboentry import ToolComboEntry
from gui.widgets.springseparator import SpringSeparatorAction
from Spell import Spell
from GrampsDisplay import url as display_url
import config
#-------------------------------------------------------------------------
#
@ -365,6 +366,11 @@ class StyledTextEditor(gtk.TextView):
spell_menu.show_all()
menu.prepend(spell_menu)
search_menu = gtk.MenuItem(_("Search selection on web"))
search_menu.connect('activate', self.search_web)
search_menu.show_all()
menu.append(search_menu)
# url menu items
if self.url_match:
flavor = self.url_match[MATCH_FLAVOR]
@ -387,12 +393,24 @@ class StyledTextEditor(gtk.TextView):
copy_menu.connect('activate', self._copy_url_cb, url, flavor)
copy_menu.show()
menu.prepend(copy_menu)
open_menu.connect('activate', self._open_url_cb, url, flavor)
open_menu.show()
menu.prepend(open_menu)
def search_web(self, widget):
"""
Search the web for selected text.
"""
selection = self.textbuffer.get_selection_bounds()
if len(selection) > 0:
display_url(config.get("behavior.web-search-url") %
{'text':
self.textbuffer.get_text(selection[0],
selection[1])})
def reset(self):
"""
Reset the undoable buffer