| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/command_updater.h" | 10 #include "chrome/browser/command_updater.h" |
| 11 #include "chrome/browser/ui/gtk/global_bookmark_menu.h" | 11 #include "chrome/browser/ui/gtk/global_bookmark_menu.h" |
| 12 #include "chrome/browser/ui/gtk/global_history_menu.h" | 12 #include "chrome/browser/ui/gtk/global_history_menu.h" |
| 13 #include "chrome/browser/ui/gtk/owned_widget_gtk.h" | 13 #include "chrome/browser/ui/gtk/owned_widget_gtk.h" |
| 14 #include "content/common/notification_observer.h" | 14 #include "content/common/notification_observer.h" |
| 15 #include "content/common/notification_registrar.h" | 15 #include "content/common/notification_registrar.h" |
| 16 #include "ui/base/gtk/gtk_signal.h" | 16 #include "ui/base/gtk/gtk_signal.h" |
| 17 | 17 |
| 18 class Browser; | 18 class Browser; |
| 19 struct GlobalMenuBarCommand; | 19 struct GlobalMenuBarCommand; |
| 20 class GlobalMenuOwner; |
| 20 | 21 |
| 21 typedef struct _GtkAccelGroup GtkAccelGroup; | 22 typedef struct _GtkAccelGroup GtkAccelGroup; |
| 22 typedef struct _GtkWidget GtkWidget; | 23 typedef struct _GtkWidget GtkWidget; |
| 23 | 24 |
| 24 // Controls the Mac style menu bar on Linux. | 25 // Controls the Mac style menu bar on Linux. |
| 25 // | 26 // |
| 26 // 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 |
| 27 // 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 |
| 28 // by inspecting the application's widget hierarchy, and intercepting any | 29 // by inspecting the application's widget hierarchy, and intercepting any |
| 29 // 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 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 41 | 42 |
| 42 explicit GlobalMenuBar(Browser* browser); | 43 explicit GlobalMenuBar(Browser* browser); |
| 43 virtual ~GlobalMenuBar(); | 44 virtual ~GlobalMenuBar(); |
| 44 | 45 |
| 45 GtkWidget* widget() { return menu_bar_.get(); } | 46 GtkWidget* widget() { return menu_bar_.get(); } |
| 46 | 47 |
| 47 private: | 48 private: |
| 48 typedef std::map<int, GtkWidget*> CommandIDMenuItemMap; | 49 typedef std::map<int, GtkWidget*> CommandIDMenuItemMap; |
| 49 | 50 |
| 50 // Helper function that builds the data. | 51 // Helper function that builds the data. |
| 51 GtkWidget* BuildGtkMenuFrom(int menu_str_id, | 52 void BuildGtkMenuFrom(int menu_str_id, |
| 52 std::map<int, GtkWidget*>* id_to_menu_item, | 53 std::map<int, GtkWidget*>* id_to_menu_item, |
| 53 GlobalMenuBarCommand* commands); | 54 GlobalMenuBarCommand* commands, |
| 55 GlobalMenuOwner* owner); |
| 54 | 56 |
| 55 // Builds an individual menu item. | 57 // Builds an individual menu item. |
| 56 GtkWidget* BuildMenuItem(int string_id, | 58 GtkWidget* BuildMenuItem(int string_id, |
| 57 int command_id, | 59 int command_id, |
| 58 int tag_id, | 60 int tag_id, |
| 59 std::map<int, GtkWidget*>* id_to_menu_item, | 61 std::map<int, GtkWidget*>* id_to_menu_item, |
| 60 GtkWidget* menu_to_add_to); | 62 GtkWidget* menu_to_add_to); |
| 61 | 63 |
| 62 // CommandUpdater::CommandObserver: | 64 // CommandUpdater::CommandObserver: |
| 63 virtual void EnabledStateChangedForCommand(int id, bool enabled); | 65 virtual void EnabledStateChangedForCommand(int id, bool enabled); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 92 // A mapping from command ids to GtkMenuItem objects. We use this to update | 94 // A mapping from command ids to GtkMenuItem objects. We use this to update |
| 93 // the command enable state. | 95 // the command enable state. |
| 94 CommandIDMenuItemMap id_to_menu_item_; | 96 CommandIDMenuItemMap id_to_menu_item_; |
| 95 | 97 |
| 96 // gtk_check_menu_item_set_active() will call the "activate" signal. We need | 98 // gtk_check_menu_item_set_active() will call the "activate" signal. We need |
| 97 // to block this activation while we change the checked state. | 99 // to block this activation while we change the checked state. |
| 98 bool block_activation_; | 100 bool block_activation_; |
| 99 }; | 101 }; |
| 100 | 102 |
| 101 #endif // CHROME_BROWSER_UI_GTK_GLOBAL_MENU_BAR_H_ | 103 #endif // CHROME_BROWSER_UI_GTK_GLOBAL_MENU_BAR_H_ |
| OLD | NEW |