summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autocomplete
diff options
context:
space:
mode:
authormattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-18 00:16:02 +0000
committermattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-18 00:16:02 +0000
commitc20bc2c92c51233dfbe73a7c776d64e7c255b6eb (patch)
tree379a6714b7da93bf83d0ce3e8e24d8d3d740721d /chrome/browser/autocomplete
parent30138a899711b9e075cd73a9e704ce858ecefdd5 (diff)
downloadchromium_src-c20bc2c92c51233dfbe73a7c776d64e7c255b6eb.zip
chromium_src-c20bc2c92c51233dfbe73a7c776d64e7c255b6eb.tar.gz
chromium_src-c20bc2c92c51233dfbe73a7c776d64e7c255b6eb.tar.bz2
Linux: Add menu item to url bar context menu to launch the search engine editor.
BUG=13326 Review URL: http://codereview.chromium.org/126307 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18671 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete')
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc24
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_gtk.h15
2 files changed, 39 insertions, 0 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc
index 26dcd2c..17e9a11 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc
@@ -7,18 +7,22 @@
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
+#include "app/l10n_util.h"
#include "base/gfx/gtk_util.h"
#include "base/logging.h"
#include "base/string_util.h"
+#include "chrome/app/chrome_dll_resource.h"
#include "chrome/browser/autocomplete/autocomplete_edit.h"
#include "chrome/browser/autocomplete/autocomplete_popup_model.h"
#include "chrome/browser/autocomplete/autocomplete_popup_view_gtk.h"
+#include "chrome/browser/command_updater.h"
#include "chrome/browser/gtk/location_bar_view_gtk.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/toolbar_model.h"
#include "chrome/common/gtk_util.h"
#include "chrome/common/notification_service.h"
#include "googleurl/src/gurl.h"
+#include "grit/generated_resources.h"
namespace {
@@ -139,6 +143,8 @@ void AutocompleteEditViewGtk::Init() {
// so we don't force a minimum width based on the text length.
g_signal_connect(text_view_, "size-request",
G_CALLBACK(&HandleViewSizeRequestThunk), this);
+ g_signal_connect(text_view_, "populate-popup",
+ G_CALLBACK(&HandlePopulatePopupThunk), this);
}
void AutocompleteEditViewGtk::SetFocus() {
@@ -498,6 +504,24 @@ void AutocompleteEditViewGtk::HandleViewSizeRequest(GtkRequisition* req) {
req->width = 1;
}
+void AutocompleteEditViewGtk::HandlePopulatePopup(GtkMenu* menu) {
+ GtkWidget* separator = gtk_separator_menu_item_new();
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), separator);
+ gtk_widget_show(separator);
+ GtkWidget* menuitem = gtk_menu_item_new_with_mnemonic(
+ gtk_util::ConvertAcceleratorsFromWindowsStyle(
+ l10n_util::GetStringUTF8(IDS_EDIT_SEARCH_ENGINES)).c_str());
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
+ g_signal_connect(menuitem, "activate",
+ G_CALLBACK(HandleEditSearchEnginesThunk), this);
+ gtk_widget_show(menuitem);
+}
+
+void AutocompleteEditViewGtk::HandleEditSearchEngines() {
+ command_updater_->ExecuteCommand(IDC_EDIT_SEARCH_ENGINES);
+}
+
+
AutocompleteEditViewGtk::CharRange AutocompleteEditViewGtk::GetSelection() {
// You can not just use get_selection_bounds here, since the order will be
// ascending, and you don't know where the user's start and end of the
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h
index ab6ebd3..d22d90e 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h
@@ -168,6 +168,21 @@ class AutocompleteEditViewGtk : public AutocompleteEditView {
}
void HandleViewSizeRequest(GtkRequisition* req);
+ static void HandlePopulatePopupThunk(GtkEntry* entry,
+ GtkMenu* menu,
+ gpointer self) {
+ reinterpret_cast<AutocompleteEditViewGtk*>(self)->
+ HandlePopulatePopup(menu);
+ }
+ void HandlePopulatePopup(GtkMenu* menu);
+
+ static void HandleEditSearchEnginesThunk(GtkMenuItem* menuitem,
+ gpointer self) {
+ reinterpret_cast<AutocompleteEditViewGtk*>(self)->
+ HandleEditSearchEngines();
+ }
+ void HandleEditSearchEngines();
+
// Get the character indices of the current selection. This honors
// direction, cp_max is the insertion point, and cp_min is the bound.
CharRange GetSelection();