Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Side by Side Diff: chrome/browser/gtk/menu_gtk.h

Issue 159815: Refactor bookmark clipboard code to be cross platform. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix UMR Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 9
10 #include <string> 10 #include <string>
11 11
12 #include "base/task.h"
12 #include "chrome/common/owned_widget_gtk.h" 13 #include "chrome/common/owned_widget_gtk.h"
13 14
14 class SkBitmap; 15 class SkBitmap;
15 16
16 struct MenuCreateMaterial; 17 struct MenuCreateMaterial;
17 18
18 class MenuGtk { 19 class MenuGtk {
19 public: 20 public:
20 // Delegate class that lets another class control the status of the menu. 21 // Delegate class that lets another class control the status of the menu.
21 class Delegate { 22 class Delegate {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 GtkAccelGroup* accel_group); 108 GtkAccelGroup* accel_group);
108 109
109 // Builds a GtkImageMenuItem. 110 // Builds a GtkImageMenuItem.
110 GtkWidget* BuildMenuItemWithImage(const std::string& label, 111 GtkWidget* BuildMenuItemWithImage(const std::string& label,
111 const SkBitmap& icon); 112 const SkBitmap& icon);
112 113
113 // A function that creates a GtkMenu from |delegate_|. This function is not 114 // A function that creates a GtkMenu from |delegate_|. This function is not
114 // recursive and does not support sub-menus. 115 // recursive and does not support sub-menus.
115 void BuildMenuFromDelegate(); 116 void BuildMenuFromDelegate();
116 117
118 // Contains implementation for OnMenuShow.
119 void UpdateMenu();
120
117 // Callback for when a menu item is clicked. 121 // Callback for when a menu item is clicked.
118 static void OnMenuItemActivated(GtkMenuItem* menuitem, MenuGtk* menu); 122 static void OnMenuItemActivated(GtkMenuItem* menuitem, MenuGtk* menu);
119 123
120 // Sets the check mark and enabled/disabled state on our menu items. 124 // Sets the check mark and enabled/disabled state on our menu items.
121 static void SetMenuItemInfo(GtkWidget* widget, void* raw_menu); 125 static void SetMenuItemInfo(GtkWidget* widget, void* raw_menu);
122 126
123 // Updates all the menu items' state. 127 // Updates all the menu items' state.
124 static void OnMenuShow(GtkWidget* widget, MenuGtk* menu); 128 static void OnMenuShow(GtkWidget* widget, MenuGtk* menu);
125 129
126 // Sets the activating widget back to a normal appearance. 130 // Sets the activating widget back to a normal appearance.
127 static void OnMenuHidden(GtkWidget* widget, MenuGtk* menu); 131 static void OnMenuHidden(GtkWidget* widget, MenuGtk* menu);
128 132
129 // Queries this object about the menu state. 133 // Queries this object about the menu state.
130 MenuGtk::Delegate* delegate_; 134 MenuGtk::Delegate* delegate_;
131 135
132 // For some menu items, we want to show the accelerator, but not actually 136 // For some menu items, we want to show the accelerator, but not actually
133 // explicitly handle it. To this end we connect those menu items' accelerators 137 // explicitly handle it. To this end we connect those menu items' accelerators
134 // to this group, but don't attach this group to any top level window. 138 // to this group, but don't attach this group to any top level window.
135 GtkAccelGroup* dummy_accel_group_; 139 GtkAccelGroup* dummy_accel_group_;
136 140
137 // gtk_menu_popup() does not appear to take ownership of popup menus, so 141 // gtk_menu_popup() does not appear to take ownership of popup menus, so
138 // MenuGtk explicitly manages the lifetime of the menu. 142 // MenuGtk explicitly manages the lifetime of the menu.
139 OwnedWidgetGtk menu_; 143 OwnedWidgetGtk menu_;
140 144
141 // True when we should ignore "activate" signals. Used to prevent 145 // True when we should ignore "activate" signals. Used to prevent
142 // menu items from getting activated when we are setting up the 146 // menu items from getting activated when we are setting up the
143 // menu. 147 // menu.
144 static bool block_activation_; 148 static bool block_activation_;
149
150 ScopedRunnableMethodFactory<MenuGtk> factory_;
145 }; 151 };
146 152
147 #endif // CHROME_BROWSER_GTK_MENU_GTK_H_ 153 #endif // CHROME_BROWSER_GTK_MENU_GTK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698