Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/back_forward_menu_model_gtk.h" | 5 #include "chrome/browser/gtk/back_forward_menu_model_gtk.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | |
| 7 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 8 #include "chrome/browser/gtk/back_forward_button_gtk.h" | 9 #include "chrome/browser/gtk/back_forward_button_gtk.h" |
| 9 | 10 |
| 11 // Might want to vary this by locale. | |
| 12 static const size_t kMaxChars = 50; | |
| 13 | |
| 10 BackForwardMenuModelGtk::BackForwardMenuModelGtk(Browser* browser, | 14 BackForwardMenuModelGtk::BackForwardMenuModelGtk(Browser* browser, |
| 11 ModelType model_type, | 15 ModelType model_type, |
| 12 BackForwardButtonGtk* button) | 16 BackForwardButtonGtk* button) |
| 13 : BackForwardMenuModel(browser, model_type), | 17 : BackForwardMenuModel(browser, model_type), |
| 14 button_(button) { | 18 button_(button) { |
| 15 } | 19 } |
| 16 | 20 |
| 17 int BackForwardMenuModelGtk::GetItemCount() const { | 21 int BackForwardMenuModelGtk::GetItemCount() const { |
| 18 return GetTotalItemCount(); | 22 return GetTotalItemCount(); |
| 19 } | 23 } |
| 20 | 24 |
| 21 bool BackForwardMenuModelGtk::IsItemSeparator(int command_id) const { | 25 bool BackForwardMenuModelGtk::IsItemSeparator(int command_id) const { |
| 22 return IsSeparator(command_id); | 26 return IsSeparator(command_id); |
| 23 } | 27 } |
| 24 | 28 |
| 25 std::string BackForwardMenuModelGtk::GetLabel(int command_id) const { | 29 std::string BackForwardMenuModelGtk::GetLabel(int command_id) const { |
| 26 return UTF16ToUTF8(GetItemLabel(command_id)); | 30 std::wstring item_label_wstr = UTF16ToWideHack(GetItemLabel(command_id)); |
| 31 // This breaks on word boundaries. Ideally we would break on character | |
| 32 // boundaries. | |
| 33 item_label_wstr = l10n_util::TruncateString(item_label_wstr, kMaxChars); | |
|
tony
2009/08/27 23:01:04
It looks like there's an width-chars property on G
Evan Stade
2009/08/27 23:02:27
The "width-chars" style property
"width-chars"
| |
| 34 return WideToUTF8(item_label_wstr); | |
| 27 } | 35 } |
| 28 | 36 |
| 29 bool BackForwardMenuModelGtk::HasIcon(int command_id) const { | 37 bool BackForwardMenuModelGtk::HasIcon(int command_id) const { |
| 30 return ItemHasIcon(command_id); | 38 return ItemHasIcon(command_id); |
| 31 } | 39 } |
| 32 | 40 |
| 33 const SkBitmap* BackForwardMenuModelGtk::GetIcon(int command_id) const { | 41 const SkBitmap* BackForwardMenuModelGtk::GetIcon(int command_id) const { |
| 34 return &GetItemIcon(command_id); | 42 return &GetItemIcon(command_id); |
| 35 } | 43 } |
| 36 | 44 |
| 37 bool BackForwardMenuModelGtk::IsCommandEnabled(int command_id) const { | 45 bool BackForwardMenuModelGtk::IsCommandEnabled(int command_id) const { |
| 38 return ItemHasCommand(command_id); | 46 return ItemHasCommand(command_id); |
| 39 } | 47 } |
| 40 | 48 |
| 41 void BackForwardMenuModelGtk::ExecuteCommand(int command_id) { | 49 void BackForwardMenuModelGtk::ExecuteCommand(int command_id) { |
| 42 ExecuteCommandById(command_id); | 50 ExecuteCommandById(command_id); |
| 43 } | 51 } |
| 44 | 52 |
| 45 void BackForwardMenuModelGtk::StoppedShowing() { | 53 void BackForwardMenuModelGtk::StoppedShowing() { |
| 46 if (button_) | 54 if (button_) |
| 47 button_->StoppedShowingMenu(); | 55 button_->StoppedShowingMenu(); |
| 48 } | 56 } |
| OLD | NEW |