Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(307)

Side by Side Diff: chrome/browser/gtk/menu_gtk.cc

Issue 56184: Don't allow hotkeys to activate un-activatable menu items. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/gtk/menu_gtk.h" 5 #include "chrome/browser/gtk/menu_gtk.h"
6 6
7 #include "base/gfx/gtk_util.h" 7 #include "base/gfx/gtk_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "chrome/common/l10n_util.h" 10 #include "chrome/common/l10n_util.h"
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 } 183 }
184 184
185 // static 185 // static
186 void MenuGtk::OnMenuItemActivated(GtkMenuItem* menuitem, MenuGtk* menu) { 186 void MenuGtk::OnMenuItemActivated(GtkMenuItem* menuitem, MenuGtk* menu) {
187 // We receive activation messages when highlighting a menu that has a 187 // We receive activation messages when highlighting a menu that has a
188 // submenu. Ignore them. 188 // submenu. Ignore them.
189 if (!gtk_menu_item_get_submenu(menuitem)) { 189 if (!gtk_menu_item_get_submenu(menuitem)) {
190 const MenuCreateMaterial* data = 190 const MenuCreateMaterial* data =
191 reinterpret_cast<const MenuCreateMaterial*>( 191 reinterpret_cast<const MenuCreateMaterial*>(
192 g_object_get_data(G_OBJECT(menuitem), "menu-data")); 192 g_object_get_data(G_OBJECT(menuitem), "menu-data"));
193 menu->delegate_->ExecuteCommand(data->id); 193 // The menu item can still be activated by hotkeys even if it is disabled.
194 if (menu->delegate_->IsCommandEnabled(data->id))
195 menu->delegate_->ExecuteCommand(data->id);
194 } 196 }
195 } 197 }
196 198
197 // static 199 // static
198 void MenuGtk::OnMenuItemActivatedById(GtkMenuItem* menuitem, MenuGtk* menu) { 200 void MenuGtk::OnMenuItemActivatedById(GtkMenuItem* menuitem, MenuGtk* menu) {
199 // We receive activation messages when highlighting a menu that has a 201 // We receive activation messages when highlighting a menu that has a
200 // submenu. Ignore them. 202 // submenu. Ignore them.
201 if (!gtk_menu_item_get_submenu(menuitem)) { 203 if (!gtk_menu_item_get_submenu(menuitem)) {
202 int id = reinterpret_cast<int>( 204 int id = reinterpret_cast<int>(
203 g_object_get_data(G_OBJECT(menuitem), "menu-id")); 205 g_object_get_data(G_OBJECT(menuitem), "menu-id"));
204 menu->delegate_->ExecuteCommand(id); 206 // The menu item can still be activated by hotkeys even if it is disabled.
207 if (menu->delegate_->IsCommandEnabled(id))
208 menu->delegate_->ExecuteCommand(id);
205 } 209 }
206 } 210 }
207 211
208 // static 212 // static
209 void MenuGtk::MenuPositionFunc(GtkMenu* menu, 213 void MenuGtk::MenuPositionFunc(GtkMenu* menu,
210 int* x, 214 int* x,
211 int* y, 215 int* y,
212 gboolean* push_in, 216 gboolean* push_in,
213 void* void_widget) { 217 void* void_widget) {
214 GtkWidget* widget = GTK_WIDGET(void_widget); 218 GtkWidget* widget = GTK_WIDGET(void_widget);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 widget, menu->delegate_->IsCommandEnabled(data->id)); 257 widget, menu->delegate_->IsCommandEnabled(data->id));
254 258
255 GtkWidget* submenu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(widget)); 259 GtkWidget* submenu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(widget));
256 if (submenu) { 260 if (submenu) {
257 gtk_container_foreach(GTK_CONTAINER(submenu), &SetMenuItemInfo, 261 gtk_container_foreach(GTK_CONTAINER(submenu), &SetMenuItemInfo,
258 userdata); 262 userdata);
259 } 263 }
260 } 264 }
261 } 265 }
262 } 266 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698