summaryrefslogtreecommitdiffstats
path: root/views/controls/menu/native_menu_gtk.cc
diff options
context:
space:
mode:
authorpinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-04 17:50:26 +0000
committerpinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-04 17:50:26 +0000
commitb284843ba6a1e90c12f91eaf796726433dc2537d (patch)
tree96edc5a4528e4d685c89544bfc13712e2984964a /views/controls/menu/native_menu_gtk.cc
parente83ce1e3f2fcacb3d400287d78567d22a2a06cae (diff)
downloadchromium_src-b284843ba6a1e90c12f91eaf796726433dc2537d.zip
chromium_src-b284843ba6a1e90c12f91eaf796726433dc2537d.tar.gz
chromium_src-b284843ba6a1e90c12f91eaf796726433dc2537d.tar.bz2
Refactor the menu model to live outside views/ so it can be shared
BUG=none TEST=none Review URL: http://codereview.chromium.org/465005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33827 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls/menu/native_menu_gtk.cc')
-rw-r--r--views/controls/menu/native_menu_gtk.cc29
1 files changed, 15 insertions, 14 deletions
diff --git a/views/controls/menu/native_menu_gtk.cc b/views/controls/menu/native_menu_gtk.cc
index f3e303b..9c5b39a 100644
--- a/views/controls/menu/native_menu_gtk.cc
+++ b/views/controls/menu/native_menu_gtk.cc
@@ -8,6 +8,7 @@
#include <string>
#include "app/gfx/gtk_util.h"
+#include "app/menus/menu_model.h"
#include "base/keyboard_codes.h"
#include "base/message_loop.h"
#include "base/string_util.h"
@@ -48,10 +49,10 @@ std::string ConvertAcceleratorsFromWindowsStyle(const std::string& label) {
}
// Returns true if the menu item type specified can be executed as a command.
-bool MenuTypeCanExecute(views::Menu2Model::ItemType type) {
- return type == views::Menu2Model::TYPE_COMMAND ||
- type == views::Menu2Model::TYPE_CHECK ||
- type == views::Menu2Model::TYPE_RADIO;
+bool MenuTypeCanExecute(menus::MenuModel::ItemType type) {
+ return type == menus::MenuModel::TYPE_COMMAND ||
+ type == menus::MenuModel::TYPE_CHECK ||
+ type == menus::MenuModel::TYPE_RADIO;
}
} // namespace
@@ -61,7 +62,7 @@ namespace views {
////////////////////////////////////////////////////////////////////////////////
// NativeMenuGtk, public:
-NativeMenuGtk::NativeMenuGtk(Menu2Model* model)
+NativeMenuGtk::NativeMenuGtk(menus::MenuModel* model)
: model_(model),
menu_(NULL),
menu_shown_(false),
@@ -105,10 +106,10 @@ void NativeMenuGtk::Rebuild() {
std::map<int, GtkRadioMenuItem*> radio_groups_;
for (int i = 0; i < model_->GetItemCount(); ++i) {
- Menu2Model::ItemType type = model_->GetTypeAt(i);
- if (type == Menu2Model::TYPE_SEPARATOR) {
+ menus::MenuModel::ItemType type = model_->GetTypeAt(i);
+ if (type == menus::MenuModel::TYPE_SEPARATOR) {
AddSeparatorAt(i);
- } else if (type == Menu2Model::TYPE_RADIO) {
+ } else if (type == menus::MenuModel::TYPE_RADIO) {
const int radio_group_id = model_->GetGroupIdAt(i);
std::map<int, GtkRadioMenuItem*>::const_iterator iter
= radio_groups_.find(radio_group_id);
@@ -160,12 +161,12 @@ GtkWidget* NativeMenuGtk::AddMenuItemAt(int index,
std::string label = ConvertAcceleratorsFromWindowsStyle(UTF16ToUTF8(
model_->GetLabelAt(index)));
- Menu2Model::ItemType type = model_->GetTypeAt(index);
+ menus::MenuModel::ItemType type = model_->GetTypeAt(index);
switch (type) {
- case Menu2Model::TYPE_CHECK:
+ case menus::MenuModel::TYPE_CHECK:
menu_item = gtk_check_menu_item_new_with_mnemonic(label.c_str());
break;
- case Menu2Model::TYPE_RADIO:
+ case menus::MenuModel::TYPE_RADIO:
if (radio_group) {
menu_item = gtk_radio_menu_item_new_with_mnemonic_from_widget(
radio_group, label.c_str());
@@ -174,8 +175,8 @@ GtkWidget* NativeMenuGtk::AddMenuItemAt(int index,
menu_item = gtk_radio_menu_item_new_with_mnemonic(NULL, label.c_str());
}
break;
- case Menu2Model::TYPE_SUBMENU:
- case Menu2Model::TYPE_COMMAND: {
+ case menus::MenuModel::TYPE_SUBMENU:
+ case menus::MenuModel::TYPE_COMMAND: {
SkBitmap icon;
// Create menu item with icon if icon exists.
if (model_->HasIcons() && model_->GetIconAt(index, &icon)) {
@@ -193,7 +194,7 @@ GtkWidget* NativeMenuGtk::AddMenuItemAt(int index,
break;
}
- if (type == Menu2Model::TYPE_SUBMENU) {
+ if (type == menus::MenuModel::TYPE_SUBMENU) {
// TODO(beng): we're leaking these objects right now... consider some other
// arrangement.
Menu2* submenu = new Menu2(model_->GetSubmenuModelAt(index));