| 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 #ifndef CHROME_BROWSER_UI_GTK_GLOBAL_MENU_BAR_H_ | 5 #ifndef CHROME_BROWSER_UI_GTK_GLOBAL_MENU_BAR_H_ |
| 6 #define CHROME_BROWSER_UI_GTK_GLOBAL_MENU_BAR_H_ | 6 #define CHROME_BROWSER_UI_GTK_GLOBAL_MENU_BAR_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "chrome/browser/command_updater.h" | 11 #include "chrome/browser/command_observer.h" |
| 12 #include "chrome/browser/prefs/pref_change_registrar.h" | 12 #include "chrome/browser/prefs/pref_change_registrar.h" |
| 13 #include "chrome/browser/ui/gtk/global_history_menu.h" | 13 #include "chrome/browser/ui/gtk/global_history_menu.h" |
| 14 #include "content/public/browser/notification_observer.h" | 14 #include "content/public/browser/notification_observer.h" |
| 15 #include "ui/base/gtk/gtk_signal.h" | 15 #include "ui/base/gtk/gtk_signal.h" |
| 16 #include "ui/base/gtk/owned_widget_gtk.h" | 16 #include "ui/base/gtk/owned_widget_gtk.h" |
| 17 | 17 |
| 18 class Browser; | 18 class Browser; |
| 19 struct GlobalMenuBarCommand; | 19 struct GlobalMenuBarCommand; |
| 20 class GlobalMenuOwner; | 20 class GlobalMenuOwner; |
| 21 | 21 |
| 22 typedef struct _GtkAccelGroup GtkAccelGroup; | 22 typedef struct _GtkAccelGroup GtkAccelGroup; |
| 23 typedef struct _GtkWidget GtkWidget; | 23 typedef struct _GtkWidget GtkWidget; |
| 24 | 24 |
| 25 // Controls the Mac style menu bar on Linux. | 25 // Controls the Mac style menu bar on Linux. |
| 26 // | 26 // |
| 27 // Unity and some configurations of GNOME have a Apple-like menu bar at the top | 27 // Unity and some configurations of GNOME have a Apple-like menu bar at the top |
| 28 // of the screen that changes depending on the active window. These mainly work | 28 // of the screen that changes depending on the active window. These mainly work |
| 29 // by inspecting the application's widget hierarchy, and intercepting any | 29 // by inspecting the application's widget hierarchy, and intercepting any |
| 30 // GtkMenuBar found. Thankfully, these systems don't check to see if the menu | 30 // GtkMenuBar found. Thankfully, these systems don't check to see if the menu |
| 31 // bar itself is visible, so we insert a GtkMenuBar into the window hierarchy | 31 // bar itself is visible, so we insert a GtkMenuBar into the window hierarchy |
| 32 // and set it to be invisible. | 32 // and set it to be invisible. |
| 33 class GlobalMenuBar : public CommandUpdater::CommandObserver, | 33 class GlobalMenuBar : public CommandObserver, |
| 34 public content::NotificationObserver { | 34 public content::NotificationObserver { |
| 35 public: | 35 public: |
| 36 static const int TAG_NORMAL = 0; | 36 static const int TAG_NORMAL = 0; |
| 37 static const int TAG_MOST_VISITED = 1; | 37 static const int TAG_MOST_VISITED = 1; |
| 38 static const int TAG_RECENTLY_CLOSED = 2; | 38 static const int TAG_RECENTLY_CLOSED = 2; |
| 39 static const int TAG_MOST_VISITED_HEADER = 3; | 39 static const int TAG_MOST_VISITED_HEADER = 3; |
| 40 static const int TAG_RECENTLY_CLOSED_HEADER = 4; | 40 static const int TAG_RECENTLY_CLOSED_HEADER = 4; |
| 41 static const int TAG_BOOKMARK_CLEARABLE = 5; | 41 static const int TAG_BOOKMARK_CLEARABLE = 5; |
| 42 | 42 |
| 43 explicit GlobalMenuBar(Browser* browser); | 43 explicit GlobalMenuBar(Browser* browser); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 58 GlobalMenuBarCommand* commands, | 58 GlobalMenuBarCommand* commands, |
| 59 GlobalMenuOwner* owner); | 59 GlobalMenuOwner* owner); |
| 60 | 60 |
| 61 // Builds an individual menu item. | 61 // Builds an individual menu item. |
| 62 GtkWidget* BuildMenuItem(int string_id, | 62 GtkWidget* BuildMenuItem(int string_id, |
| 63 int command_id, | 63 int command_id, |
| 64 int tag_id, | 64 int tag_id, |
| 65 std::map<int, GtkWidget*>* id_to_menu_item, | 65 std::map<int, GtkWidget*>* id_to_menu_item, |
| 66 GtkWidget* menu_to_add_to); | 66 GtkWidget* menu_to_add_to); |
| 67 | 67 |
| 68 // CommandUpdater::CommandObserver: | 68 // CommandObserver: |
| 69 virtual void EnabledStateChangedForCommand(int id, bool enabled) OVERRIDE; | 69 virtual void EnabledStateChangedForCommand(int id, bool enabled) OVERRIDE; |
| 70 | 70 |
| 71 // content::NotificationObserver: | 71 // content::NotificationObserver: |
| 72 virtual void Observe(int type, | 72 virtual void Observe(int type, |
| 73 const content::NotificationSource& source, | 73 const content::NotificationSource& source, |
| 74 const content::NotificationDetails& details) OVERRIDE; | 74 const content::NotificationDetails& details) OVERRIDE; |
| 75 | 75 |
| 76 // Updates the visibility of the bookmark bar on pref changes. | 76 // Updates the visibility of the bookmark bar on pref changes. |
| 77 void OnBookmarkBarVisibilityChanged(); | 77 void OnBookmarkBarVisibilityChanged(); |
| 78 | 78 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 98 // A mapping from command ids to GtkMenuItem objects. We use this to update | 98 // A mapping from command ids to GtkMenuItem objects. We use this to update |
| 99 // the command enable state. | 99 // the command enable state. |
| 100 CommandIDMenuItemMap id_to_menu_item_; | 100 CommandIDMenuItemMap id_to_menu_item_; |
| 101 | 101 |
| 102 // gtk_check_menu_item_set_active() will call the "activate" signal. We need | 102 // gtk_check_menu_item_set_active() will call the "activate" signal. We need |
| 103 // to block this activation while we change the checked state. | 103 // to block this activation while we change the checked state. |
| 104 bool block_activation_; | 104 bool block_activation_; |
| 105 }; | 105 }; |
| 106 | 106 |
| 107 #endif // CHROME_BROWSER_UI_GTK_GLOBAL_MENU_BAR_H_ | 107 #endif // CHROME_BROWSER_UI_GTK_GLOBAL_MENU_BAR_H_ |
| OLD | NEW |