OLD | NEW |
---|---|
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #ifndef CHROME_BROWSER_BROWSER_TOOLBAR_VIEW_GTK_H_ | 5 #ifndef CHROME_BROWSER_GTK_BROWSER_TOOLBAR_VIEW_GTK_H_ |
6 #define CHROME_BROWSER_BROWSER_TOOLBAR_VIEW_GTK_H_ | 6 #define CHROME_BROWSER_GTK_BROWSER_TOOLBAR_VIEW_GTK_H_ |
7 | |
8 #include "chrome/browser/command_updater.h" | |
9 #include "chrome/common/pref_member.h" | |
10 | 7 |
11 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 #include <string> | |
10 | |
11 #include "base/scoped_ptr.h" | |
12 #include "chrome/browser/command_updater.h" | |
13 #include "chrome/browser/gtk/menu_gtk.h" | |
14 #include "chrome/common/pref_member.h" | |
12 | 15 |
13 class Browser; | 16 class Browser; |
14 class Profile; | 17 class Profile; |
15 class ToolbarModel; | 18 class ToolbarModel; |
16 | 19 |
17 // View class that displays the GTK version of the toolbar and routes gtk | 20 // View class that displays the GTK version of the toolbar and routes gtk |
18 // events back to the Browser. | 21 // events back to the Browser. |
19 class BrowserToolbarGtk : public CommandUpdater::CommandObserver { | 22 class BrowserToolbarGtk : public CommandUpdater::CommandObserver, |
23 public MenuGtk::Delegate { | |
20 public: | 24 public: |
21 explicit BrowserToolbarGtk(Browser* browser); | 25 explicit BrowserToolbarGtk(Browser* browser); |
22 virtual ~BrowserToolbarGtk(); | 26 virtual ~BrowserToolbarGtk(); |
23 | 27 |
24 // Create the contents of the toolbar | 28 // Create the contents of the toolbar |
25 void Init(Profile* profile); | 29 void Init(Profile* profile); |
26 | 30 |
27 // Adds this GTK toolbar into a sizing box. | 31 // Adds this GTK toolbar into a sizing box. |
28 void AddToolbarToBox(GtkWidget* box); | 32 void AddToolbarToBox(GtkWidget* box); |
29 | 33 |
30 // Overridden from CommandUpdater::CommandObserver: | 34 // Overridden from CommandUpdater::CommandObserver: |
31 virtual void EnabledStateChangedForCommand(int id, bool enabled); | 35 virtual void EnabledStateChangedForCommand(int id, bool enabled); |
32 | 36 |
37 // Overridden from MenuGtk::Delegate: | |
38 virtual bool IsCommandEnabled(int command_id) const; | |
39 virtual bool IsItemChecked(int id) const; | |
40 virtual void ExecuteCommand(int command_id); | |
41 | |
33 void SetProfile(Profile* profile); | 42 void SetProfile(Profile* profile); |
34 | 43 |
35 private: | 44 private: |
36 class CustomDrawButton; // Defined in the .cc file. | 45 class CustomDrawButton; // Defined in the .cc file. |
37 | 46 |
38 // Builds a toolbar button with all the properties set. | 47 // Builds a toolbar button with all the properties set. |
39 CustomDrawButton* BuildToolbarButton(const std::string& filename, | 48 CustomDrawButton* BuildToolbarButton(const std::string& filename, |
40 const std::wstring& localized_tooltip); | 49 const std::wstring& localized_tooltip, |
50 bool menu_button); | |
41 | 51 |
42 // Gtk callback for the "clicked" signal. | 52 // Gtk callback for the "clicked" signal. |
43 static void ButtonClickCallback(GtkWidget* button, | 53 static void OnButtonClick(GtkWidget* button, BrowserToolbarGtk* toolbar); |
44 BrowserToolbarGtk* toolbar); | 54 |
55 // Gtk callback to intercept mouse clicks to the menu buttons. | |
Evan Martin
2009/02/17 19:08:24
i guess "intercept" is sort of the wrong word -- i
| |
56 static gint OnMenuButtonPressEvent(GtkWidget* button, | |
57 GdkEvent *event, | |
Evan Martin
2009/02/17 19:08:24
tabbing weird here
| |
58 BrowserToolbarGtk* toolbar); | |
59 | |
60 // Displays the page menu. | |
61 void RunPageMenu(GdkEvent* button_press_event); | |
62 | |
63 // Displays the app menu. | |
64 void RunAppMenu(GdkEvent* button_press_event); | |
45 | 65 |
46 // Gtk widgets. The toolbar is an hbox with each of the other pieces of the | 66 // Gtk widgets. The toolbar is an hbox with each of the other pieces of the |
47 // toolbar placed side by side. | 67 // toolbar placed side by side. |
48 GtkWidget* toolbar_; | 68 GtkWidget* toolbar_; |
49 | 69 |
50 // Tooltip container for all GTK widgets in this class. | 70 // Tooltip container for all GTK widgets in this class. |
51 GtkTooltips* toolbar_tooltips_; | 71 GtkTooltips* toolbar_tooltips_; |
52 | 72 |
53 // All the buttons in the toolbar. | 73 // All the buttons in the toolbar. |
54 scoped_ptr<CustomDrawButton> back_, forward_; | 74 scoped_ptr<CustomDrawButton> back_, forward_; |
55 scoped_ptr<CustomDrawButton> reload_, home_; | 75 scoped_ptr<CustomDrawButton> reload_, home_; |
56 scoped_ptr<CustomDrawButton> star_, go_; | 76 scoped_ptr<CustomDrawButton> star_, go_; |
57 scoped_ptr<CustomDrawButton> page_menu_, app_menu_; | 77 scoped_ptr<CustomDrawButton> page_menu_button_, app_menu_button_; |
58 | 78 |
59 // The model that contains the security level, text, icon to display... | 79 // The model that contains the security level, text, icon to display... |
60 ToolbarModel* model_; | 80 ToolbarModel* model_; |
61 | 81 |
82 scoped_ptr<MenuGtk> page_menu_; | |
83 scoped_ptr<MenuGtk> app_menu_; | |
84 | |
62 // TODO(port): Port BackForwardMenuModel | 85 // TODO(port): Port BackForwardMenuModel |
63 // scoped_ptr<BackForwardMenuModel> back_menu_model_; | 86 // scoped_ptr<BackForwardMenuModel> back_menu_model_; |
64 // scoped_ptr<BackForwardMenuModel> forward_menu_model_; | 87 // scoped_ptr<BackForwardMenuModel> forward_menu_model_; |
65 | 88 |
66 Browser* browser_; | 89 Browser* browser_; |
67 Profile* profile_; | 90 Profile* profile_; |
68 | 91 |
69 // Controls whether or not a home button should be shown on the toolbar. | 92 // Controls whether or not a home button should be shown on the toolbar. |
70 BooleanPrefMember show_home_button_; | 93 BooleanPrefMember show_home_button_; |
71 }; | 94 }; |
72 | 95 |
73 #endif | 96 #endif // CHROME_BROWSER_GTK_BROWSER_TOOLBAR_VIEW_GTK_H_ |
OLD | NEW |