Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "app/menus/accelerator_gtk.h" | 9 #include "app/menus/accelerator_gtk.h" |
| 10 #include "app/menus/button_menu_item_model.h" | 10 #include "app/menus/button_menu_item_model.h" |
| (...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 796 gtk_custom_menu_item_foreach_button(GTK_CUSTOM_MENU_ITEM(widget), | 796 gtk_custom_menu_item_foreach_button(GTK_CUSTOM_MENU_ITEM(widget), |
| 797 SetButtonItemInfo, | 797 SetButtonItemInfo, |
| 798 userdata); | 798 userdata); |
| 799 } | 799 } |
| 800 | 800 |
| 801 if (GTK_IS_MENU_ITEM(widget)) { | 801 if (GTK_IS_MENU_ITEM(widget)) { |
| 802 gtk_widget_set_sensitive(widget, model->IsEnabledAt(id)); | 802 gtk_widget_set_sensitive(widget, model->IsEnabledAt(id)); |
| 803 | 803 |
| 804 if (model->IsVisibleAt(id)) { | 804 if (model->IsVisibleAt(id)) { |
| 805 // Update the menu item label if it is dynamic. | 805 // Update the menu item label if it is dynamic. |
| 806 // TODO(atwilson): Update the icon as well (http://crbug.com/66508). | |
| 807 if (model->IsItemDynamicAt(id)) { | 806 if (model->IsItemDynamicAt(id)) { |
| 808 std::string label = | 807 std::string label = |
| 809 gfx::ConvertAcceleratorsFromWindowsStyle( | 808 gfx::ConvertAcceleratorsFromWindowsStyle( |
| 810 UTF16ToUTF8(model->GetLabelAt(id))); | 809 UTF16ToUTF8(model->GetLabelAt(id))); |
| 811 | 810 |
| 812 #if GTK_CHECK_VERSION(2, 16, 0) | 811 #if GTK_CHECK_VERSION(2, 16, 0) |
| 813 gtk_menu_item_set_label(GTK_MENU_ITEM(widget), label.c_str()); | 812 gtk_menu_item_set_label(GTK_MENU_ITEM(widget), label.c_str()); |
| 814 #else | 813 #else |
| 815 gtk_label_set_label(GTK_LABEL(GTK_BIN(widget)->child), label.c_str()); | 814 gtk_label_set_label(GTK_LABEL(GTK_BIN(widget)->child), label.c_str()); |
|
Evan Stade
2010/12/23 02:36:43
side note.
I wonder if this actually works for Gt
| |
| 816 #endif | 815 #endif |
| 816 if (GTK_IS_IMAGE_MENU_ITEM(widget)) { | |
| 817 SkBitmap icon; | |
| 818 if (model->GetIconAt(id, &icon)) { | |
| 819 GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&icon); | |
| 820 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(widget), | |
| 821 gtk_image_new_from_pixbuf(pixbuf)); | |
| 822 g_object_unref(pixbuf); | |
| 823 } else { | |
| 824 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(widget), NULL); | |
| 825 } | |
| 826 } | |
| 817 } | 827 } |
| 818 | 828 |
| 819 gtk_widget_show(widget); | 829 gtk_widget_show(widget); |
| 820 } else { | 830 } else { |
| 821 gtk_widget_hide(widget); | 831 gtk_widget_hide(widget); |
| 822 } | 832 } |
| 823 | 833 |
| 824 GtkWidget* submenu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(widget)); | 834 GtkWidget* submenu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(widget)); |
| 825 if (submenu) { | 835 if (submenu) { |
| 826 gtk_container_foreach(GTK_CONTAINER(submenu), &SetMenuItemInfo, | 836 gtk_container_foreach(GTK_CONTAINER(submenu), &SetMenuItemInfo, |
| 827 userdata); | 837 userdata); |
| 828 } | 838 } |
| 829 } | 839 } |
| 830 } | 840 } |
| OLD | NEW |