blob: 462c122693f42b7dcfeed2c4a4714148729911e8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_GTK_MENU_GTK_H_
#define CHROME_BROWSER_GTK_MENU_GTK_H_
#include <gtk/gtk.h>
#include "chrome/browser/gtk/standard_menus.h"
class MenuGtk {
public:
// Delegate class that lets another class control the status of the menu.
class Delegate {
public:
virtual ~Delegate() { }
// Returns whether the menu item for this command should be enabled.
virtual bool IsCommandEnabled(int command_id) const = 0;
// Returns whether this command.
virtual bool IsItemChecked(int command_id) const = 0;
// Executes the command.
virtual void ExecuteCommand(int command_id) = 0;
};
MenuGtk(MenuGtk::Delegate* delegate, const MenuCreateMaterial* menu_data);
~MenuGtk();
// Displays the menu
void Popup(GtkWidget* widget, GdkEvent* event);
private:
// A recursive function that transforms a MenuCreateMaterial tree into a set
// of GtkMenuItems.
void BuildMenuIn(GtkWidget* menu, const MenuCreateMaterial* menu_data);
// Callback for when a menu item is clicked.
static void OnMenuItemActivated(GtkMenuItem* menuitem, MenuGtk* menu);
// Repositions the menu to be right under the button.
static void MenuPositionFunc(GtkMenu* menu,
int* x,
int* y,
gboolean* push_in,
void* void_widget);
// Sets the check mark and enabled/disabled state on our menu items.
static void SetMenuItemInfo(GtkWidget* widget, void* raw_menu);
// Queries this object about the menu state.
MenuGtk::Delegate* delegate_;
// gtk_menu_popup() does not appear to take ownership of popup menus, so
// MenuGtk explicitly manages the lifetime of the menu.
GtkWidget* menu_;
};
#endif // CHROME_BROWSER_GTK_MENU_GTK_H_
|