| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-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/standard_menus.h" | 5 #include "chrome/browser/gtk/standard_menus.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 #include <gdk/gdkkeysyms.h> | 8 #include <gdk/gdkkeysyms.h> |
| 9 | 9 |
| 10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "chrome/app/chrome_dll_resource.h" | 12 #include "chrome/app/chrome_dll_resource.h" |
| 13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/encoding_menu_controller.h" | 14 #include "chrome/browser/encoding_menu_controller.h" |
| 15 #include "chrome/browser/profile.h" |
| 15 #include "grit/chromium_strings.h" | 16 #include "grit/chromium_strings.h" |
| 16 #include "grit/generated_resources.h" | 17 #include "grit/generated_resources.h" |
| 17 | 18 |
| 18 namespace { | 19 namespace { |
| 19 | 20 |
| 20 struct MenuCreateMaterial zoom_menu_materials[] = { | 21 struct MenuCreateMaterial zoom_menu_materials[] = { |
| 21 { MENU_NORMAL, IDC_ZOOM_PLUS, IDS_ZOOM_PLUS, 0, NULL, | 22 { MENU_NORMAL, IDC_ZOOM_PLUS, IDS_ZOOM_PLUS, 0, NULL, |
| 22 GDK_KP_Add, GDK_CONTROL_MASK }, | 23 GDK_KP_Add, GDK_CONTROL_MASK }, |
| 23 { MENU_NORMAL, IDC_ZOOM_NORMAL, IDS_ZOOM_NORMAL, 0, NULL, | 24 { MENU_NORMAL, IDC_ZOOM_NORMAL, IDS_ZOOM_NORMAL, 0, NULL, |
| 24 GDK_KP_0, GDK_CONTROL_MASK }, | 25 GDK_KP_0, GDK_CONTROL_MASK }, |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 { MENU_SEPARATOR }, | 101 { MENU_SEPARATOR }, |
| 101 { MENU_NORMAL, IDC_EXIT, IDS_EXIT, 0, NULL, GDK_q, | 102 { MENU_NORMAL, IDC_EXIT, IDS_EXIT, 0, NULL, GDK_q, |
| 102 GDK_CONTROL_MASK | GDK_SHIFT_MASK }, | 103 GDK_CONTROL_MASK | GDK_SHIFT_MASK }, |
| 103 #endif | 104 #endif |
| 104 { MENU_END } | 105 { MENU_END } |
| 105 }; | 106 }; |
| 106 | 107 |
| 107 } // namespace | 108 } // namespace |
| 108 | 109 |
| 109 | 110 |
| 110 const MenuCreateMaterial* GetStandardPageMenu(MenuGtk* encodings_menu) { | 111 const MenuCreateMaterial* GetStandardPageMenu(Profile* profile, |
| 112 MenuGtk::Delegate* delegate) { |
| 113 EncodingMenuController controller; |
| 114 EncodingMenuController::EncodingMenuItemList items; |
| 115 controller.GetEncodingMenuItems(profile, &items); |
| 116 |
| 117 MenuGtk* encodings_menu = new MenuGtk(delegate, false); |
| 118 GSList* radio_group = NULL; |
| 119 for (EncodingMenuController::EncodingMenuItemList::const_iterator i = |
| 120 items.begin(); |
| 121 i != items.end(); ++i) { |
| 122 if (i == items.begin()) { |
| 123 encodings_menu->AppendCheckMenuItemWithLabel(i->first, |
| 124 UTF16ToUTF8(i->second)); |
| 125 } else if (i->first == 0) { |
| 126 encodings_menu->AppendSeparator(); |
| 127 } else { |
| 128 GtkWidget* item = |
| 129 gtk_radio_menu_item_new_with_label(radio_group, |
| 130 UTF16ToUTF8(i->second).c_str()); |
| 131 radio_group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(item)); |
| 132 encodings_menu->AppendMenuItem(i->first, item); |
| 133 } |
| 134 } |
| 135 |
| 111 // Find the encoding menu and attach this menu. | 136 // Find the encoding menu and attach this menu. |
| 112 for (MenuCreateMaterial* entry = standard_page_menu_materials; | 137 for (MenuCreateMaterial* entry = standard_page_menu_materials; |
| 113 entry->type != MENU_END; ++entry) { | 138 entry->type != MENU_END; ++entry) { |
| 114 if (entry->id == IDC_ENCODING_MENU) { | 139 if (entry->id == IDC_ENCODING_MENU) { |
| 115 entry->custom_submenu = encodings_menu; | 140 entry->custom_submenu = encodings_menu; |
| 116 } else if (entry->id == IDC_DEVELOPER_MENU) { | 141 } else if (entry->id == IDC_DEVELOPER_MENU) { |
| 117 entry->submenu = g_browser_process->have_inspector_files() ? | 142 entry->submenu = g_browser_process->have_inspector_files() ? |
| 118 developer_menu_materials : developer_menu_materials_no_inspector; | 143 developer_menu_materials : developer_menu_materials_no_inspector; |
| 119 } | 144 } |
| 120 } | 145 } |
| 121 | 146 |
| 122 return standard_page_menu_materials; | 147 return standard_page_menu_materials; |
| 123 } | 148 } |
| 124 | 149 |
| 125 const MenuCreateMaterial* GetStandardAppMenu() { | 150 const MenuCreateMaterial* GetStandardAppMenu() { |
| 126 return standard_app_menu_materials; | 151 return standard_app_menu_materials; |
| 127 } | 152 } |
| OLD | NEW |