Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(755)

Side by Side Diff: chrome/browser/ui/gtk/global_menu_bar.cc

Issue 9965049: ui/base: Clean up our AcceleratorGtk class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sky review Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/global_menu_bar.h" 5 #include "chrome/browser/ui/gtk/global_menu_bar.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "chrome/app/chrome_command_ids.h" 10 #include "chrome/app/chrome_command_ids.h"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 BuildGtkMenuFrom(IDS_HELP_MENU_LINUX, &id_to_menu_item_, help_menu, NULL); 167 BuildGtkMenuFrom(IDS_HELP_MENU_LINUX, &id_to_menu_item_, help_menu, NULL);
168 168
169 for (CommandIDMenuItemMap::const_iterator it = id_to_menu_item_.begin(); 169 for (CommandIDMenuItemMap::const_iterator it = id_to_menu_item_.begin();
170 it != id_to_menu_item_.end(); ++it) { 170 it != id_to_menu_item_.end(); ++it) {
171 // Get the starting enabled state. 171 // Get the starting enabled state.
172 gtk_widget_set_sensitive( 172 gtk_widget_set_sensitive(
173 it->second, 173 it->second,
174 browser_->command_updater()->IsCommandEnabled(it->first)); 174 browser_->command_updater()->IsCommandEnabled(it->first));
175 175
176 // Set the accelerator for each menu item. 176 // Set the accelerator for each menu item.
177 const ui::AcceleratorGtk* accelerator_gtk = 177 AcceleratorsGtk* accelerators = AcceleratorsGtk::GetInstance();
178 AcceleratorsGtk::GetInstance()->GetPrimaryAcceleratorForCommand( 178 const ui::AcceleratorGtk* accelerator =
179 it->first); 179 accelerators->GetPrimaryAcceleratorForCommand(it->first);
180 if (accelerator_gtk) { 180 if (accelerator) {
181 gtk_widget_add_accelerator(it->second, 181 gtk_widget_add_accelerator(it->second,
182 "activate", 182 "activate",
183 dummy_accel_group_, 183 dummy_accel_group_,
184 accelerator_gtk->GetGdkKeyCode(), 184 accelerator->GetGdkKeyCode(),
185 accelerator_gtk->gdk_modifier_type(), 185 accelerator->gdk_modifier_type(),
186 GTK_ACCEL_VISIBLE); 186 GTK_ACCEL_VISIBLE);
187 } 187 }
188 188
189 browser_->command_updater()->AddCommandObserver(it->first, this); 189 browser_->command_updater()->AddCommandObserver(it->first, this);
190 } 190 }
191 191
192 pref_change_registrar_.Init(browser_->profile()->GetPrefs()); 192 pref_change_registrar_.Init(browser_->profile()->GetPrefs());
193 pref_change_registrar_.Add(prefs::kShowBookmarkBar, this); 193 pref_change_registrar_.Add(prefs::kShowBookmarkBar, this);
194 OnBookmarkBarVisibilityChanged(); 194 OnBookmarkBarVisibilityChanged();
195 } 195 }
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 } 304 }
305 } 305 }
306 306
307 void GlobalMenuBar::OnItemActivated(GtkWidget* sender) { 307 void GlobalMenuBar::OnItemActivated(GtkWidget* sender) {
308 if (block_activation_) 308 if (block_activation_)
309 return; 309 return;
310 310
311 int id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(sender), "command-id")); 311 int id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(sender), "command-id"));
312 browser_->ExecuteCommandIfEnabled(id); 312 browser_->ExecuteCommandIfEnabled(id);
313 } 313 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/extensions/extension_keybinding_registry_gtk.cc ('k') | ui/base/accelerators/accelerator_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698