diff --git a/src/config.py b/src/config.py index 36f278954..91a7ff85e 100644 --- a/src/config.py +++ b/src/config.py @@ -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], diff --git a/src/gui/widgets/styledtexteditor.py b/src/gui/widgets/styledtexteditor.py index 2f9cc0437..106127d7a 100644 --- a/src/gui/widgets/styledtexteditor.py +++ b/src/gui/widgets/styledtexteditor.py @@ -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