| 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_GTK_MENU_GTK_H_ | 5 #ifndef CHROME_BROWSER_GTK_MENU_GTK_H_ |
| 6 #define CHROME_BROWSER_GTK_MENU_GTK_H_ | 6 #define CHROME_BROWSER_GTK_MENU_GTK_H_ |
| 7 | 7 |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 // Displays the menu using the button type and timestamp of |event|. The popup | 53 // Displays the menu using the button type and timestamp of |event|. The popup |
| 54 // is statically positioned at |widget|. | 54 // is statically positioned at |widget|. |
| 55 void Popup(GtkWidget* widget, GdkEvent* event); | 55 void Popup(GtkWidget* widget, GdkEvent* event); |
| 56 | 56 |
| 57 // Displays the menu as a context menu, i.e. at the current cursor location. | 57 // Displays the menu as a context menu, i.e. at the current cursor location. |
| 58 void PopupAsContext(); | 58 void PopupAsContext(); |
| 59 | 59 |
| 60 private: | 60 private: |
| 61 // A recursive function that transforms a MenuCreateMaterial tree into a set | 61 // A recursive function that transforms a MenuCreateMaterial tree into a set |
| 62 // of GtkMenuItems. | 62 // of GtkMenuItems. |
| 63 void BuildMenuIn(GtkWidget* menu, const MenuCreateMaterial* menu_data); | 63 void BuildMenuIn(GtkWidget* menu, |
| 64 const MenuCreateMaterial* menu_data, |
| 65 GtkAccelGroup* accel_group); |
| 64 | 66 |
| 65 // A function that creates a GtkMenu from |delegate_|. This function is not | 67 // A function that creates a GtkMenu from |delegate_|. This function is not |
| 66 // recursive and does not support sub-menus. | 68 // recursive and does not support sub-menus. |
| 67 void BuildMenuFromDelegate(); | 69 void BuildMenuFromDelegate(); |
| 68 | 70 |
| 69 // Callback for when a menu item is clicked. Used when the menu is created | 71 // Callback for when a menu item is clicked. Used when the menu is created |
| 70 // via a MenuCreateMaterial. | 72 // via a MenuCreateMaterial. |
| 71 static void OnMenuItemActivated(GtkMenuItem* menuitem, MenuGtk* menu); | 73 static void OnMenuItemActivated(GtkMenuItem* menuitem, MenuGtk* menu); |
| 72 | 74 |
| 73 // Callback for when a menu item is clicked. Used when the menu is created | 75 // Callback for when a menu item is clicked. Used when the menu is created |
| (...skipping 10 matching lines...) Expand all Loading... |
| 84 int* y, | 86 int* y, |
| 85 gboolean* push_in, | 87 gboolean* push_in, |
| 86 void* void_widget); | 88 void* void_widget); |
| 87 | 89 |
| 88 // Sets the check mark and enabled/disabled state on our menu items. | 90 // Sets the check mark and enabled/disabled state on our menu items. |
| 89 static void SetMenuItemInfo(GtkWidget* widget, void* raw_menu); | 91 static void SetMenuItemInfo(GtkWidget* widget, void* raw_menu); |
| 90 | 92 |
| 91 // Queries this object about the menu state. | 93 // Queries this object about the menu state. |
| 92 MenuGtk::Delegate* delegate_; | 94 MenuGtk::Delegate* delegate_; |
| 93 | 95 |
| 94 // Accelerator group to add keyboard accelerators to. | |
| 95 GtkAccelGroup* accel_group_; | |
| 96 | |
| 97 // gtk_menu_popup() does not appear to take ownership of popup menus, so | 96 // gtk_menu_popup() does not appear to take ownership of popup menus, so |
| 98 // MenuGtk explicitly manages the lifetime of the menu. | 97 // MenuGtk explicitly manages the lifetime of the menu. |
| 99 OwnedWidgetGtk menu_; | 98 OwnedWidgetGtk menu_; |
| 100 }; | 99 }; |
| 101 | 100 |
| 102 #endif // CHROME_BROWSER_GTK_MENU_GTK_H_ | 101 #endif // CHROME_BROWSER_GTK_MENU_GTK_H_ |
| OLD | NEW |