| OLD | NEW |
| 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/browser_actions_toolbar_gtk.h" | 5 #include "chrome/browser/ui/gtk/browser_actions_toolbar_gtk.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 void BrowserActionsToolbarGtk::AnimationEnded(const ui::Animation* animation) { | 784 void BrowserActionsToolbarGtk::AnimationEnded(const ui::Animation* animation) { |
| 785 gtk_widget_set_size_request(button_hbox_.get(), desired_width_, -1); | 785 gtk_widget_set_size_request(button_hbox_.get(), desired_width_, -1); |
| 786 UpdateChevronVisibility(); | 786 UpdateChevronVisibility(); |
| 787 } | 787 } |
| 788 | 788 |
| 789 bool BrowserActionsToolbarGtk::IsCommandIdChecked(int command_id) const { | 789 bool BrowserActionsToolbarGtk::IsCommandIdChecked(int command_id) const { |
| 790 return false; | 790 return false; |
| 791 } | 791 } |
| 792 | 792 |
| 793 bool BrowserActionsToolbarGtk::IsCommandIdEnabled(int command_id) const { | 793 bool BrowserActionsToolbarGtk::IsCommandIdEnabled(int command_id) const { |
| 794 const Extension* extension = model_->GetExtensionByIndex(command_id); | 794 const Extension* extension = model_->toolbar_items_by_index(command_id); |
| 795 return extension->browser_action()->GetIsVisible(GetCurrentTabId()); | 795 return extension->browser_action()->GetIsVisible(GetCurrentTabId()); |
| 796 } | 796 } |
| 797 | 797 |
| 798 bool BrowserActionsToolbarGtk::GetAcceleratorForCommandId( | 798 bool BrowserActionsToolbarGtk::GetAcceleratorForCommandId( |
| 799 int command_id, | 799 int command_id, |
| 800 ui::Accelerator* accelerator) { | 800 ui::Accelerator* accelerator) { |
| 801 return false; | 801 return false; |
| 802 } | 802 } |
| 803 | 803 |
| 804 void BrowserActionsToolbarGtk::ExecuteCommand(int command_id) { | 804 void BrowserActionsToolbarGtk::ExecuteCommand(int command_id) { |
| 805 const Extension* extension = model_->GetExtensionByIndex(command_id); | 805 const Extension* extension = model_->toolbar_items_by_index(command_id); |
| 806 GURL popup_url; | 806 GURL popup_url; |
| 807 | 807 |
| 808 switch (model_->ExecuteBrowserAction(extension, browser(), &popup_url)) { | 808 switch (model_->ExecuteBrowserAction(extension, browser(), &popup_url)) { |
| 809 case ExtensionToolbarModel::ACTION_NONE: | 809 case ExtensionToolbarModel::ACTION_NONE: |
| 810 break; | 810 break; |
| 811 case ExtensionToolbarModel::ACTION_SHOW_POPUP: | 811 case ExtensionToolbarModel::ACTION_SHOW_POPUP: |
| 812 ExtensionPopupGtk::Show(popup_url, browser(), chevron(), | 812 ExtensionPopupGtk::Show(popup_url, browser(), chevron(), |
| 813 ExtensionPopupGtk::SHOW); | 813 ExtensionPopupGtk::SHOW); |
| 814 break; | 814 break; |
| 815 } | 815 } |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1026 overflow_menu_model_.reset(new SimpleMenuModel(this)); | 1026 overflow_menu_model_.reset(new SimpleMenuModel(this)); |
| 1027 | 1027 |
| 1028 int visible_icon_count = | 1028 int visible_icon_count = |
| 1029 gtk_chrome_shrinkable_hbox_get_visible_child_count( | 1029 gtk_chrome_shrinkable_hbox_get_visible_child_count( |
| 1030 GTK_CHROME_SHRINKABLE_HBOX(button_hbox_.get())); | 1030 GTK_CHROME_SHRINKABLE_HBOX(button_hbox_.get())); |
| 1031 for (int i = visible_icon_count; i < button_count(); ++i) { | 1031 for (int i = visible_icon_count; i < button_count(); ++i) { |
| 1032 int model_index = i; | 1032 int model_index = i; |
| 1033 if (profile_->IsOffTheRecord()) | 1033 if (profile_->IsOffTheRecord()) |
| 1034 model_index = model_->IncognitoIndexToOriginal(i); | 1034 model_index = model_->IncognitoIndexToOriginal(i); |
| 1035 | 1035 |
| 1036 const Extension* extension = model_->GetExtensionByIndex(model_index); | 1036 const Extension* extension = model_->toolbar_items_by_index(model_index); |
| 1037 BrowserActionButton* button = extension_button_map_[extension->id()].get(); | 1037 BrowserActionButton* button = extension_button_map_[extension->id()].get(); |
| 1038 | 1038 |
| 1039 overflow_menu_model_->AddItem(model_index, UTF8ToUTF16(extension->name())); | 1039 overflow_menu_model_->AddItem(model_index, UTF8ToUTF16(extension->name())); |
| 1040 overflow_menu_model_->SetIcon(overflow_menu_model_->GetItemCount() - 1, | 1040 overflow_menu_model_->SetIcon(overflow_menu_model_->GetItemCount() - 1, |
| 1041 button->GetIcon()); | 1041 button->GetIcon()); |
| 1042 | 1042 |
| 1043 // TODO(estade): set the menu item's tooltip. | 1043 // TODO(estade): set the menu item's tooltip. |
| 1044 } | 1044 } |
| 1045 | 1045 |
| 1046 overflow_menu_.reset(new MenuGtk(this, overflow_menu_model_.get())); | 1046 overflow_menu_.reset(new MenuGtk(this, overflow_menu_model_.get())); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1066 if (item_index == -1) { | 1066 if (item_index == -1) { |
| 1067 NOTREACHED(); | 1067 NOTREACHED(); |
| 1068 return FALSE; | 1068 return FALSE; |
| 1069 } | 1069 } |
| 1070 | 1070 |
| 1071 item_index += gtk_chrome_shrinkable_hbox_get_visible_child_count( | 1071 item_index += gtk_chrome_shrinkable_hbox_get_visible_child_count( |
| 1072 GTK_CHROME_SHRINKABLE_HBOX(button_hbox_.get())); | 1072 GTK_CHROME_SHRINKABLE_HBOX(button_hbox_.get())); |
| 1073 if (profile_->IsOffTheRecord()) | 1073 if (profile_->IsOffTheRecord()) |
| 1074 item_index = model_->IncognitoIndexToOriginal(item_index); | 1074 item_index = model_->IncognitoIndexToOriginal(item_index); |
| 1075 | 1075 |
| 1076 const Extension* extension = model_->GetExtensionByIndex(item_index); | 1076 const Extension* extension = model_->toolbar_items_by_index(item_index); |
| 1077 ExtensionButtonMap::iterator it = extension_button_map_.find( | 1077 ExtensionButtonMap::iterator it = extension_button_map_.find( |
| 1078 extension->id()); | 1078 extension->id()); |
| 1079 if (it == extension_button_map_.end()) { | 1079 if (it == extension_button_map_.end()) { |
| 1080 NOTREACHED(); | 1080 NOTREACHED(); |
| 1081 return FALSE; | 1081 return FALSE; |
| 1082 } | 1082 } |
| 1083 | 1083 |
| 1084 MenuGtk* menu = it->second.get()->GetContextMenu(); | 1084 MenuGtk* menu = it->second.get()->GetContextMenu(); |
| 1085 if (!menu) | 1085 if (!menu) |
| 1086 return FALSE; | 1086 return FALSE; |
| 1087 | 1087 |
| 1088 menu->PopupAsContext(gfx::Point(event->x_root, event->y_root), | 1088 menu->PopupAsContext(gfx::Point(event->x_root, event->y_root), |
| 1089 event->time); | 1089 event->time); |
| 1090 return TRUE; | 1090 return TRUE; |
| 1091 } | 1091 } |
| 1092 | 1092 |
| 1093 void BrowserActionsToolbarGtk::OnButtonShowOrHide(GtkWidget* sender) { | 1093 void BrowserActionsToolbarGtk::OnButtonShowOrHide(GtkWidget* sender) { |
| 1094 if (!resize_animation_.is_animating()) | 1094 if (!resize_animation_.is_animating()) |
| 1095 UpdateChevronVisibility(); | 1095 UpdateChevronVisibility(); |
| 1096 } | 1096 } |
| OLD | NEW |