| OLD | NEW |
| 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 "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/gfx/gtk_util.h" | 8 #include "base/gfx/gtk_util.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/stl_util-inl.h" | 10 #include "base/stl_util-inl.h" |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 // submenu. Ignore them. | 226 // submenu. Ignore them. |
| 227 if (!gtk_menu_item_get_submenu(menuitem)) { | 227 if (!gtk_menu_item_get_submenu(menuitem)) { |
| 228 const MenuCreateMaterial* data = | 228 const MenuCreateMaterial* data = |
| 229 reinterpret_cast<const MenuCreateMaterial*>( | 229 reinterpret_cast<const MenuCreateMaterial*>( |
| 230 g_object_get_data(G_OBJECT(menuitem), "menu-data")); | 230 g_object_get_data(G_OBJECT(menuitem), "menu-data")); |
| 231 | 231 |
| 232 int id; | 232 int id; |
| 233 if (data) { | 233 if (data) { |
| 234 id = data->id; | 234 id = data->id; |
| 235 } else { | 235 } else { |
| 236 id = reinterpret_cast<int>(g_object_get_data(G_OBJECT(menuitem), | 236 id = reinterpret_cast<intptr_t>(g_object_get_data(G_OBJECT(menuitem), |
| 237 "menu-id")); | 237 "menu-id")); |
| 238 } | 238 } |
| 239 | 239 |
| 240 // The menu item can still be activated by hotkeys even if it is disabled. | 240 // The menu item can still be activated by hotkeys even if it is disabled. |
| 241 if (menu->delegate_->IsCommandEnabled(id)) | 241 if (menu->delegate_->IsCommandEnabled(id)) |
| 242 menu->delegate_->ExecuteCommand(id); | 242 menu->delegate_->ExecuteCommand(id); |
| 243 } | 243 } |
| 244 } | 244 } |
| 245 | 245 |
| 246 // static | 246 // static |
| 247 void MenuGtk::MenuPositionFunc(GtkMenu* menu, | 247 void MenuGtk::MenuPositionFunc(GtkMenu* menu, |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 } | 302 } |
| 303 | 303 |
| 304 MenuGtk* menu = reinterpret_cast<MenuGtk*>(userdata); | 304 MenuGtk* menu = reinterpret_cast<MenuGtk*>(userdata); |
| 305 int id; | 305 int id; |
| 306 const MenuCreateMaterial* data = | 306 const MenuCreateMaterial* data = |
| 307 reinterpret_cast<const MenuCreateMaterial*>( | 307 reinterpret_cast<const MenuCreateMaterial*>( |
| 308 g_object_get_data(G_OBJECT(widget), "menu-data")); | 308 g_object_get_data(G_OBJECT(widget), "menu-data")); |
| 309 if (data) { | 309 if (data) { |
| 310 id = data->id; | 310 id = data->id; |
| 311 } else { | 311 } else { |
| 312 id = reinterpret_cast<int>( | 312 id = reinterpret_cast<intptr_t>(g_object_get_data(G_OBJECT(widget), |
| 313 g_object_get_data(G_OBJECT(widget), "menu-id")); | 313 "menu-id")); |
| 314 } | 314 } |
| 315 | 315 |
| 316 if (GTK_IS_CHECK_MENU_ITEM(widget)) { | 316 if (GTK_IS_CHECK_MENU_ITEM(widget)) { |
| 317 GtkCheckMenuItem* item = GTK_CHECK_MENU_ITEM(widget); | 317 GtkCheckMenuItem* item = GTK_CHECK_MENU_ITEM(widget); |
| 318 | 318 |
| 319 // gtk_check_menu_item_set_active() will send the activate signal. Touching | 319 // gtk_check_menu_item_set_active() will send the activate signal. Touching |
| 320 // the underlying "active" property will also call the "activate" handler | 320 // the underlying "active" property will also call the "activate" handler |
| 321 // for this menu item. So we prevent the "activate" handler from | 321 // for this menu item. So we prevent the "activate" handler from |
| 322 // being called while we set the checkbox. | 322 // being called while we set the checkbox. |
| 323 g_signal_handlers_block_matched( | 323 g_signal_handlers_block_matched( |
| (...skipping 16 matching lines...) Expand all Loading... |
| 340 gtk_widget_set_sensitive( | 340 gtk_widget_set_sensitive( |
| 341 widget, menu->delegate_->IsCommandEnabled(id)); | 341 widget, menu->delegate_->IsCommandEnabled(id)); |
| 342 | 342 |
| 343 GtkWidget* submenu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(widget)); | 343 GtkWidget* submenu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(widget)); |
| 344 if (submenu) { | 344 if (submenu) { |
| 345 gtk_container_foreach(GTK_CONTAINER(submenu), &SetMenuItemInfo, | 345 gtk_container_foreach(GTK_CONTAINER(submenu), &SetMenuItemInfo, |
| 346 userdata); | 346 userdata); |
| 347 } | 347 } |
| 348 } | 348 } |
| 349 } | 349 } |
| OLD | NEW |