Chromium Code Reviews| 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_MENU_GTK_H_ | 5 #ifndef CHROME_BROWSER_UI_GTK_MENU_GTK_H_ |
| 6 #define CHROME_BROWSER_UI_GTK_MENU_GTK_H_ | 6 #define CHROME_BROWSER_UI_GTK_MENU_GTK_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
| 10 | 10 |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/task.h" | 14 #include "base/task.h" |
| 15 #include "ui/base/gtk/gtk_signal.h" | 15 #include "ui/base/gtk/gtk_signal.h" |
| 16 #include "ui/base/models/menu_model.h" | |
| 16 #include "ui/gfx/point.h" | 17 #include "ui/gfx/point.h" |
| 17 | 18 |
| 18 class SkBitmap; | 19 class SkBitmap; |
| 19 | 20 |
| 20 namespace ui { | 21 namespace ui { |
| 21 class ButtonMenuItemModel; | 22 class ButtonMenuItemModel; |
| 22 class MenuModel; | |
| 23 } | 23 } |
| 24 | 24 |
| 25 class MenuGtk { | 25 class MenuGtk : public ui::MenuModelDelegate { |
| 26 public: | 26 public: |
| 27 // Delegate class that lets another class control the status of the menu. | 27 // Delegate class that lets another class control the status of the menu. |
| 28 class Delegate { | 28 class Delegate { |
| 29 public: | 29 public: |
| 30 virtual ~Delegate() { } | 30 virtual ~Delegate() { } |
| 31 | 31 |
| 32 // Called before a command is executed. This exists for the case where a | 32 // Called before a command is executed. This exists for the case where a |
| 33 // model is handling the actual execution of commands, but the delegate | 33 // model is handling the actual execution of commands, but the delegate |
| 34 // still needs to know that some command got executed. This is called before | 34 // still needs to know that some command got executed. This is called before |
| 35 // and not after the command is executed because its execution may delete | 35 // and not after the command is executed because its execution may delete |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 91 void PopupAsContextForStatusIcon(guint32 event_time, guint32 button, | 91 void PopupAsContextForStatusIcon(guint32 event_time, guint32 button, |
| 92 GtkStatusIcon* icon); | 92 GtkStatusIcon* icon); |
| 93 | 93 |
| 94 // Displays the menu following a keyboard event (such as selecting |widget| | 94 // Displays the menu following a keyboard event (such as selecting |widget| |
| 95 // and pressing "enter"). | 95 // and pressing "enter"). |
| 96 void PopupAsFromKeyEvent(GtkWidget* widget); | 96 void PopupAsFromKeyEvent(GtkWidget* widget); |
| 97 | 97 |
| 98 // Closes the menu. | 98 // Closes the menu. |
| 99 void Cancel(); | 99 void Cancel(); |
| 100 | 100 |
| 101 // From ui::MenuModelDelegate, called when a favicon is loaded from history. | |
| 102 virtual void OnIconChanged(int model_index); | |
|
Avi (use Gerrit)
2011/03/25 00:19:35
OVERRIDE
| |
| 103 | |
| 104 // Update the icon for a particular menu_item (widget). | |
| 105 static void UpdateMenuIcon(GtkWidget* widget, gpointer userdata); | |
|
sky
2011/03/24 22:39:29
Why is this public?
| |
| 106 | |
| 101 // Repositions the menu to be right under the button. Alignment is set as | 107 // Repositions the menu to be right under the button. Alignment is set as |
| 102 // object data on |void_widget| with the tag "left_align". If "left_align" | 108 // object data on |void_widget| with the tag "left_align". If "left_align" |
| 103 // is true, it aligns the left side of the menu with the left side of the | 109 // is true, it aligns the left side of the menu with the left side of the |
| 104 // button. Otherwise it aligns the right side of the menu with the right side | 110 // button. Otherwise it aligns the right side of the menu with the right side |
| 105 // of the button. Public since some menus have odd requirements that don't | 111 // of the button. Public since some menus have odd requirements that don't |
| 106 // belong in a public class. | 112 // belong in a public class. |
| 107 static void WidgetMenuPositionFunc(GtkMenu* menu, | 113 static void WidgetMenuPositionFunc(GtkMenu* menu, |
| 108 int* x, | 114 int* x, |
| 109 int* y, | 115 int* y, |
| 110 gboolean* push_in, | 116 gboolean* push_in, |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 187 // menu. | 193 // menu. |
| 188 static bool block_activation_; | 194 static bool block_activation_; |
| 189 | 195 |
| 190 // We must free these at shutdown. | 196 // We must free these at shutdown. |
| 191 std::vector<MenuGtk*> submenus_we_own_; | 197 std::vector<MenuGtk*> submenus_we_own_; |
| 192 | 198 |
| 193 ScopedRunnableMethodFactory<MenuGtk> factory_; | 199 ScopedRunnableMethodFactory<MenuGtk> factory_; |
| 194 }; | 200 }; |
| 195 | 201 |
| 196 #endif // CHROME_BROWSER_UI_GTK_MENU_GTK_H_ | 202 #endif // CHROME_BROWSER_UI_GTK_MENU_GTK_H_ |
| OLD | NEW |