| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/ui/libgtk2ui/menu_util.h" | 5 #include "chrome/browser/ui/libgtk2ui/menu_util.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/app/chrome_command_ids.h" | 8 #include "chrome/app/chrome_command_ids.h" |
| 9 #include "chrome/browser/ui/libgtk2ui/gtk2_util.h" | 9 #include "chrome/browser/ui/libgtk2ui/gtk2_util.h" |
| 10 #include "chrome/browser/ui/libgtk2ui/skia_utils_gtk2.h" | 10 #include "chrome/browser/ui/libgtk2ui/skia_utils_gtk2.h" |
| 11 #include "ui/base/accelerators/accelerator.h" | 11 #include "ui/base/accelerators/accelerator.h" |
| 12 #include "ui/base/accelerators/menu_label_accelerator_util_linux.h" | 12 #include "ui/base/accelerators/menu_label_accelerator_util_linux.h" |
| 13 #include "ui/base/models/menu_model.h" | 13 #include "ui/base/models/menu_model.h" |
| 14 | 14 |
| 15 G_GNUC_BEGIN_IGNORE_DEPRECATIONS |
| 16 |
| 15 namespace libgtk2ui { | 17 namespace libgtk2ui { |
| 16 | 18 |
| 17 GtkWidget* BuildMenuItemWithImage(const std::string& label, GtkWidget* image) { | 19 GtkWidget* BuildMenuItemWithImage(const std::string& label, GtkWidget* image) { |
| 18 GtkWidget* menu_item = gtk_image_menu_item_new_with_mnemonic(label.c_str()); | 20 GtkWidget* menu_item = gtk_image_menu_item_new_with_mnemonic(label.c_str()); |
| 19 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item), image); | 21 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item), image); |
| 20 return menu_item; | 22 return menu_item; |
| 21 } | 23 } |
| 22 | 24 |
| 23 GtkWidget* BuildMenuItemWithImage(const std::string& label, | 25 GtkWidget* BuildMenuItemWithImage(const std::string& label, |
| 24 const gfx::Image& icon) { | 26 const gfx::Image& icon) { |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 NOTIMPLEMENTED(); | 134 NOTIMPLEMENTED(); |
| 133 break; | 135 break; |
| 134 } | 136 } |
| 135 case ui::MenuModel::TYPE_SUBMENU: | 137 case ui::MenuModel::TYPE_SUBMENU: |
| 136 case ui::MenuModel::TYPE_COMMAND: { | 138 case ui::MenuModel::TYPE_COMMAND: { |
| 137 if (model->GetIconAt(i, &icon)) | 139 if (model->GetIconAt(i, &icon)) |
| 138 menu_item = BuildMenuItemWithImage(label, icon); | 140 menu_item = BuildMenuItemWithImage(label, icon); |
| 139 else | 141 else |
| 140 menu_item = BuildMenuItemWithLabel(label); | 142 menu_item = BuildMenuItemWithLabel(label); |
| 141 if (GTK_IS_IMAGE_MENU_ITEM(menu_item)) { | 143 if (GTK_IS_IMAGE_MENU_ITEM(menu_item)) { |
| 142 SetAlwaysShowImage(menu_item); | 144 gtk_image_menu_item_set_always_show_image( |
| 145 GTK_IMAGE_MENU_ITEM(menu_item), TRUE); |
| 143 } | 146 } |
| 144 break; | 147 break; |
| 145 } | 148 } |
| 146 | 149 |
| 147 default: | 150 default: |
| 148 NOTREACHED(); | 151 NOTREACHED(); |
| 149 } | 152 } |
| 150 | 153 |
| 151 if (model->GetTypeAt(i) == ui::MenuModel::TYPE_SUBMENU) { | 154 if (model->GetTypeAt(i) == ui::MenuModel::TYPE_SUBMENU) { |
| 152 GtkWidget* submenu = gtk_menu_new(); | 155 GtkWidget* submenu = gtk_menu_new(); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 | 255 |
| 253 GtkWidget* submenu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(widget)); | 256 GtkWidget* submenu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(widget)); |
| 254 if (submenu) { | 257 if (submenu) { |
| 255 gtk_container_foreach( | 258 gtk_container_foreach( |
| 256 GTK_CONTAINER(submenu), &SetMenuItemInfo, block_activation_ptr); | 259 GTK_CONTAINER(submenu), &SetMenuItemInfo, block_activation_ptr); |
| 257 } | 260 } |
| 258 } | 261 } |
| 259 } | 262 } |
| 260 | 263 |
| 261 } // namespace libgtk2ui | 264 } // namespace libgtk2ui |
| OLD | NEW |