| 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/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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 gtk_widget_show(menu_item); | 274 gtk_widget_show(menu_item); |
| 275 return menu_item; | 275 return menu_item; |
| 276 } | 276 } |
| 277 | 277 |
| 278 void GlobalMenuBar::EnabledStateChangedForCommand(int id, bool enabled) { | 278 void GlobalMenuBar::EnabledStateChangedForCommand(int id, bool enabled) { |
| 279 CommandIDMenuItemMap::iterator it = id_to_menu_item_.find(id); | 279 CommandIDMenuItemMap::iterator it = id_to_menu_item_.find(id); |
| 280 if (it != id_to_menu_item_.end()) | 280 if (it != id_to_menu_item_.end()) |
| 281 gtk_widget_set_sensitive(it->second, enabled); | 281 gtk_widget_set_sensitive(it->second, enabled); |
| 282 } | 282 } |
| 283 | 283 |
| 284 void GlobalMenuBar::Observe(int type, | 284 void GlobalMenuBar::OnPreferenceChanged(PrefServiceBase* service, |
| 285 const content::NotificationSource& source, | 285 const std::string& pref_name) { |
| 286 const content::NotificationDetails& details) { | |
| 287 DCHECK_EQ(chrome::NOTIFICATION_PREF_CHANGED, type); | |
| 288 const std::string& pref_name = *content::Details<std::string>(details).ptr(); | |
| 289 DCHECK_EQ(prefs::kShowBookmarkBar, pref_name); | 286 DCHECK_EQ(prefs::kShowBookmarkBar, pref_name); |
| 290 OnBookmarkBarVisibilityChanged(); | 287 OnBookmarkBarVisibilityChanged(); |
| 291 } | 288 } |
| 292 | 289 |
| 293 void GlobalMenuBar::OnBookmarkBarVisibilityChanged() { | 290 void GlobalMenuBar::OnBookmarkBarVisibilityChanged() { |
| 294 CommandIDMenuItemMap::iterator it = | 291 CommandIDMenuItemMap::iterator it = |
| 295 id_to_menu_item_.find(IDC_SHOW_BOOKMARK_BAR); | 292 id_to_menu_item_.find(IDC_SHOW_BOOKMARK_BAR); |
| 296 if (it != id_to_menu_item_.end()) { | 293 if (it != id_to_menu_item_.end()) { |
| 297 PrefService* prefs = browser_->profile()->GetPrefs(); | 294 PrefService* prefs = browser_->profile()->GetPrefs(); |
| 298 block_activation_ = true; | 295 block_activation_ = true; |
| 299 gtk_check_menu_item_set_active( | 296 gtk_check_menu_item_set_active( |
| 300 GTK_CHECK_MENU_ITEM(it->second), | 297 GTK_CHECK_MENU_ITEM(it->second), |
| 301 prefs->GetBoolean(prefs::kShowBookmarkBar)); | 298 prefs->GetBoolean(prefs::kShowBookmarkBar)); |
| 302 block_activation_ = false; | 299 block_activation_ = false; |
| 303 } | 300 } |
| 304 } | 301 } |
| 305 | 302 |
| 306 void GlobalMenuBar::OnItemActivated(GtkWidget* sender) { | 303 void GlobalMenuBar::OnItemActivated(GtkWidget* sender) { |
| 307 if (block_activation_) | 304 if (block_activation_) |
| 308 return; | 305 return; |
| 309 | 306 |
| 310 int id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(sender), "command-id")); | 307 int id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(sender), "command-id")); |
| 311 chrome::ExecuteCommand(browser_, id); | 308 chrome::ExecuteCommand(browser_, id); |
| 312 } | 309 } |
| OLD | NEW |