2023-01-26 10:15:55 +00:00
|
|
|
// Copyright 2014 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 ELECTRON_SHELL_BROWSER_UI_GTK_MENU_GTK_H_
|
|
|
|
#define ELECTRON_SHELL_BROWSER_UI_GTK_MENU_GTK_H_
|
|
|
|
|
2023-02-03 11:43:42 +00:00
|
|
|
#include "base/functional/callback.h"
|
2023-01-26 10:15:55 +00:00
|
|
|
#include "base/memory/raw_ptr.h"
|
|
|
|
#include "ui/base/glib/scoped_gobject.h"
|
2023-10-05 23:59:39 +00:00
|
|
|
#include "ui/base/glib/scoped_gsignal.h"
|
2023-01-26 10:15:55 +00:00
|
|
|
|
|
|
|
typedef struct _GtkMenu GtkMenu;
|
|
|
|
typedef struct _GtkWidget GtkWidget;
|
|
|
|
|
|
|
|
namespace ui {
|
|
|
|
class MenuModel;
|
|
|
|
}
|
|
|
|
|
2023-04-11 06:30:25 +00:00
|
|
|
namespace electron::gtkui {
|
2023-01-26 10:15:55 +00:00
|
|
|
|
|
|
|
class MenuGtk {
|
|
|
|
public:
|
|
|
|
explicit MenuGtk(ui::MenuModel* model);
|
|
|
|
virtual ~MenuGtk();
|
|
|
|
|
|
|
|
// Refreshes all the menu item labels and menu item checked/enabled states.
|
|
|
|
void Refresh();
|
|
|
|
|
|
|
|
GtkMenu* GetGtkMenu();
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Callback for when a menu item is activated.
|
2023-10-05 23:59:39 +00:00
|
|
|
void OnMenuItemActivated(GtkWidget* menu_item);
|
2023-01-26 10:15:55 +00:00
|
|
|
|
|
|
|
raw_ptr<ui::MenuModel> menu_model_; // not owned
|
|
|
|
ScopedGObject<GtkWidget> gtk_menu_;
|
|
|
|
|
|
|
|
bool block_activation_ = false;
|
2023-10-05 23:59:39 +00:00
|
|
|
std::vector<ScopedGSignal> signals_;
|
2023-01-26 10:15:55 +00:00
|
|
|
};
|
|
|
|
|
2023-04-11 06:30:25 +00:00
|
|
|
} // namespace electron::gtkui
|
2023-01-26 10:15:55 +00:00
|
|
|
|
|
|
|
#endif // ELECTRON_SHELL_BROWSER_UI_GTK_MENU_GTK_H_
|