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 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 716 } | 716 } |
| 717 | 717 |
| 718 // static | 718 // static |
| 719 void MenuGtk::SetButtonItemInfo(GtkWidget* button, gpointer userdata) { | 719 void MenuGtk::SetButtonItemInfo(GtkWidget* button, gpointer userdata) { |
| 720 menus::ButtonMenuItemModel* model = | 720 menus::ButtonMenuItemModel* model = |
| 721 reinterpret_cast<menus::ButtonMenuItemModel*>( | 721 reinterpret_cast<menus::ButtonMenuItemModel*>( |
| 722 g_object_get_data(G_OBJECT(button), "button-model")); | 722 g_object_get_data(G_OBJECT(button), "button-model")); |
| 723 int index = GPOINTER_TO_INT(g_object_get_data( | 723 int index = GPOINTER_TO_INT(g_object_get_data( |
| 724 G_OBJECT(button), "button-model-id")); | 724 G_OBJECT(button), "button-model-id")); |
| 725 | 725 |
| 726 if (model->IsLabelDynamicAt(index)) { | 726 if (model->IsItemDynamicAt(index)) { |
| 727 std::string label = | 727 std::string label = |
| 728 gfx::ConvertAcceleratorsFromWindowsStyle( | 728 gfx::ConvertAcceleratorsFromWindowsStyle( |
| 729 UTF16ToUTF8(model->GetLabelAt(index))); | 729 UTF16ToUTF8(model->GetLabelAt(index))); |
| 730 gtk_button_set_label(GTK_BUTTON(button), label.c_str()); | 730 gtk_button_set_label(GTK_BUTTON(button), label.c_str()); |
| 731 } | 731 } |
| 732 | 732 |
| 733 gtk_widget_set_sensitive(GTK_WIDGET(button), model->IsEnabledAt(index)); | 733 gtk_widget_set_sensitive(GTK_WIDGET(button), model->IsEnabledAt(index)); |
| 734 } | 734 } |
| 735 | 735 |
| 736 // static | 736 // static |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 775 gtk_custom_menu_item_foreach_button(GTK_CUSTOM_MENU_ITEM(widget), | 775 gtk_custom_menu_item_foreach_button(GTK_CUSTOM_MENU_ITEM(widget), |
| 776 SetButtonItemInfo, | 776 SetButtonItemInfo, |
| 777 userdata); | 777 userdata); |
| 778 } | 778 } |
| 779 | 779 |
| 780 if (GTK_IS_MENU_ITEM(widget)) { | 780 if (GTK_IS_MENU_ITEM(widget)) { |
| 781 gtk_widget_set_sensitive(widget, model->IsEnabledAt(id)); | 781 gtk_widget_set_sensitive(widget, model->IsEnabledAt(id)); |
| 782 | 782 |
| 783 if (model->IsVisibleAt(id)) { | 783 if (model->IsVisibleAt(id)) { |
| 784 // Update the menu item label if it is dynamic. | 784 // Update the menu item label if it is dynamic. |
| 785 if (model->IsLabelDynamicAt(id)) { | 785 if (model->IsItemDynamicAt(id)) { |
|
Evan Stade
2010/12/14 01:20:13
add TODO re: images (also in the native_menu_* fil
Andrew T Wilson (Slow)
2010/12/14 18:23:27
Done.
BTW, where are the native_menu_* implementa
Evan Stade
2010/12/14 21:28:57
I think that's because the common pattern is to ju
| |
| 786 std::string label = | 786 std::string label = |
| 787 gfx::ConvertAcceleratorsFromWindowsStyle( | 787 gfx::ConvertAcceleratorsFromWindowsStyle( |
| 788 UTF16ToUTF8(model->GetLabelAt(id))); | 788 UTF16ToUTF8(model->GetLabelAt(id))); |
| 789 | 789 |
| 790 #if GTK_CHECK_VERSION(2, 16, 0) | 790 #if GTK_CHECK_VERSION(2, 16, 0) |
| 791 gtk_menu_item_set_label(GTK_MENU_ITEM(widget), label.c_str()); | 791 gtk_menu_item_set_label(GTK_MENU_ITEM(widget), label.c_str()); |
| 792 #else | 792 #else |
| 793 gtk_label_set_label(GTK_LABEL(GTK_BIN(widget)->child), label.c_str()); | 793 gtk_label_set_label(GTK_LABEL(GTK_BIN(widget)->child), label.c_str()); |
| 794 #endif | 794 #endif |
| 795 } | 795 } |
| 796 | 796 |
| 797 gtk_widget_show(widget); | 797 gtk_widget_show(widget); |
| 798 } else { | 798 } else { |
| 799 gtk_widget_hide(widget); | 799 gtk_widget_hide(widget); |
| 800 } | 800 } |
| 801 | 801 |
| 802 GtkWidget* submenu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(widget)); | 802 GtkWidget* submenu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(widget)); |
| 803 if (submenu) { | 803 if (submenu) { |
| 804 gtk_container_foreach(GTK_CONTAINER(submenu), &SetMenuItemInfo, | 804 gtk_container_foreach(GTK_CONTAINER(submenu), &SetMenuItemInfo, |
| 805 userdata); | 805 userdata); |
| 806 } | 806 } |
| 807 } | 807 } |
| 808 } | 808 } |
| OLD | NEW |