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

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

Issue 10437006: Converts ui/views/controls, ui/views/examples, ui/base/models to ImageSkia (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 8 years, 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/gtk/menu_gtk.h" 5 #include "chrome/browser/ui/gtk/menu_gtk.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 } 438 }
439 439
440 void MenuGtk::BuildMenuFromModel() { 440 void MenuGtk::BuildMenuFromModel() {
441 BuildSubmenuFromModel(model_, menu_); 441 BuildSubmenuFromModel(model_, menu_);
442 } 442 }
443 443
444 void MenuGtk::BuildSubmenuFromModel(ui::MenuModel* model, GtkWidget* menu) { 444 void MenuGtk::BuildSubmenuFromModel(ui::MenuModel* model, GtkWidget* menu) {
445 std::map<int, GtkWidget*> radio_groups; 445 std::map<int, GtkWidget*> radio_groups;
446 GtkWidget* menu_item = NULL; 446 GtkWidget* menu_item = NULL;
447 for (int i = 0; i < model->GetItemCount(); ++i) { 447 for (int i = 0; i < model->GetItemCount(); ++i) {
448 SkBitmap icon; 448 gfx::ImageSkia icon;
449 std::string label = ui::ConvertAcceleratorsFromWindowsStyle( 449 std::string label = ui::ConvertAcceleratorsFromWindowsStyle(
450 UTF16ToUTF8(model->GetLabelAt(i))); 450 UTF16ToUTF8(model->GetLabelAt(i)));
451 bool connect_to_activate = true; 451 bool connect_to_activate = true;
452 452
453 switch (model->GetTypeAt(i)) { 453 switch (model->GetTypeAt(i)) {
454 case ui::MenuModel::TYPE_SEPARATOR: 454 case ui::MenuModel::TYPE_SEPARATOR:
455 menu_item = gtk_separator_menu_item_new(); 455 menu_item = gtk_separator_menu_item_new();
456 break; 456 break;
457 457
458 case ui::MenuModel::TYPE_CHECK: 458 case ui::MenuModel::TYPE_CHECK:
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 gtk_widget_set_sensitive(widget, model->IsEnabledAt(id)); 869 gtk_widget_set_sensitive(widget, model->IsEnabledAt(id));
870 870
871 if (model->IsVisibleAt(id)) { 871 if (model->IsVisibleAt(id)) {
872 // Update the menu item label if it is dynamic. 872 // Update the menu item label if it is dynamic.
873 if (model->IsItemDynamicAt(id)) { 873 if (model->IsItemDynamicAt(id)) {
874 std::string label = ui::ConvertAcceleratorsFromWindowsStyle( 874 std::string label = ui::ConvertAcceleratorsFromWindowsStyle(
875 UTF16ToUTF8(model->GetLabelAt(id))); 875 UTF16ToUTF8(model->GetLabelAt(id)));
876 876
877 gtk_menu_item_set_label(GTK_MENU_ITEM(widget), label.c_str()); 877 gtk_menu_item_set_label(GTK_MENU_ITEM(widget), label.c_str());
878 if (GTK_IS_IMAGE_MENU_ITEM(widget)) { 878 if (GTK_IS_IMAGE_MENU_ITEM(widget)) {
879 SkBitmap icon; 879 gfx::ImageSkia icon;
880 if (model->GetIconAt(id, &icon)) { 880 if (model->GetIconAt(id, &icon)) {
881 GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(icon); 881 GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(icon);
882 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(widget), 882 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(widget),
883 gtk_image_new_from_pixbuf(pixbuf)); 883 gtk_image_new_from_pixbuf(pixbuf));
884 g_object_unref(pixbuf); 884 g_object_unref(pixbuf);
885 } else { 885 } else {
886 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(widget), NULL); 886 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(widget), NULL);
887 } 887 }
888 } 888 }
889 } 889 }
890 890
891 gtk_widget_show(widget); 891 gtk_widget_show(widget);
892 } else { 892 } else {
893 gtk_widget_hide(widget); 893 gtk_widget_hide(widget);
894 } 894 }
895 895
896 GtkWidget* submenu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(widget)); 896 GtkWidget* submenu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(widget));
897 if (submenu) { 897 if (submenu) {
898 gtk_container_foreach(GTK_CONTAINER(submenu), &SetMenuItemInfo, 898 gtk_container_foreach(GTK_CONTAINER(submenu), &SetMenuItemInfo,
899 userdata); 899 userdata);
900 } 900 }
901 } 901 }
902 } 902 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698