| 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/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 GtkWidget* MenuGtk::BuildMenuItemWithImage(const std::string& label, | 203 GtkWidget* MenuGtk::BuildMenuItemWithImage(const std::string& label, |
| 204 const SkBitmap& icon) { | 204 const SkBitmap& icon) { |
| 205 std::string converted_label = ConvertAcceleratorsFromWindowsStyle(label); | 205 std::string converted_label = ConvertAcceleratorsFromWindowsStyle(label); |
| 206 GtkWidget* menu_item = | 206 GtkWidget* menu_item = |
| 207 gtk_image_menu_item_new_with_mnemonic(converted_label.c_str()); | 207 gtk_image_menu_item_new_with_mnemonic(converted_label.c_str()); |
| 208 | 208 |
| 209 GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&icon); | 209 GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&icon); |
| 210 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item), | 210 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item), |
| 211 gtk_image_new_from_pixbuf(pixbuf)); | 211 gtk_image_new_from_pixbuf(pixbuf)); |
| 212 g_object_unref(pixbuf); | 212 g_object_unref(pixbuf); |
| 213 if (delegate_->AlwaysShowImages()) |
| 214 gtk_util::SetAlwaysShowImage(menu_item); |
| 213 | 215 |
| 214 return menu_item; | 216 return menu_item; |
| 215 } | 217 } |
| 216 | 218 |
| 217 void MenuGtk::BuildMenuFromDelegate() { | 219 void MenuGtk::BuildMenuFromDelegate() { |
| 218 // Note that the menu IDs start at 1, not 0. | 220 // Note that the menu IDs start at 1, not 0. |
| 219 for (int i = 1; i <= delegate_->GetItemCount(); ++i) { | 221 for (int i = 1; i <= delegate_->GetItemCount(); ++i) { |
| 220 GtkWidget* menu_item = NULL; | 222 GtkWidget* menu_item = NULL; |
| 221 | 223 |
| 222 if (delegate_->IsItemSeparator(i)) { | 224 if (delegate_->IsItemSeparator(i)) { |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 gtk_widget_set_sensitive( | 361 gtk_widget_set_sensitive( |
| 360 widget, menu->delegate_->IsCommandEnabled(id)); | 362 widget, menu->delegate_->IsCommandEnabled(id)); |
| 361 | 363 |
| 362 GtkWidget* submenu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(widget)); | 364 GtkWidget* submenu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(widget)); |
| 363 if (submenu) { | 365 if (submenu) { |
| 364 gtk_container_foreach(GTK_CONTAINER(submenu), &SetMenuItemInfo, | 366 gtk_container_foreach(GTK_CONTAINER(submenu), &SetMenuItemInfo, |
| 365 userdata); | 367 userdata); |
| 366 } | 368 } |
| 367 } | 369 } |
| 368 } | 370 } |
| OLD | NEW |