Cadabra
Computer algebra system for field theory problems
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
cdb::ContextMenu Class Reference

Description

A right-click context menu.

gtkmm-3 builds one from Gtk::Menu + Gtk::MenuItem and pops it up at the pointer. Both of those classes are gone in GTK4, where a menu is a Gio::Menu model whose items name actions, shown through a Gtk::PopoverMenu parented to the widget. This wrapper hides the difference so the call sites read the same on both.

#include <GtkCompat.hh>

Public Member Functions

 ContextMenu ()=default
 
 ContextMenu (const ContextMenu &)=delete
 
ContextMenu & operator= (const ContextMenu &)=delete
 
 ~ContextMenu ()
 
void attach_to (Gtk::Widget &widget, const Glib::ustring &action_prefix)
 Call once, before add_item().
 
void add_item (const Glib::ustring &label, const sigc::slot< void()> &callback)
 
void popup_at (double x, double y)
 x, y are relative to the widget passed to attach_to().
 

Private Attributes

Gtk::Menu menu
 

Constructor & Destructor Documentation

◆ ContextMenu() [1/2]

cdb::ContextMenu::ContextMenu ( )
default

◆ ContextMenu() [2/2]

cdb::ContextMenu::ContextMenu ( const ContextMenu &  )
delete

◆ ~ContextMenu()

cdb::ContextMenu::~ContextMenu ( )
inline

Member Function Documentation

◆ add_item()

void cdb::ContextMenu::add_item ( const Glib::ustring &  label,
const sigc::slot< void()> &  callback 
)
inline

◆ attach_to()

void cdb::ContextMenu::attach_to ( Gtk::Widget &  widget,
const Glib::ustring &  action_prefix 
)
inline

Call once, before add_item().

action_prefix only has to be unique within widget.

◆ operator=()

ContextMenu & cdb::ContextMenu::operator= ( const ContextMenu &  )
delete

◆ popup_at()

void cdb::ContextMenu::popup_at ( double  x,
double  y 
)
inline

x, y are relative to the widget passed to attach_to().

Member Data Documentation

◆ menu

Gtk::Menu cdb::ContextMenu::menu
private

The documentation for this class was generated from the following file: