Cadabra
Computer algebra system for field theory problems
Loading...
Searching...
No Matches
Classes | Namespaces | Typedefs | Enumerations | Functions | Variables
GtkCompat.hh File Reference

Compatibility helpers that let the gtkmm frontend build against both gtkmm-3 and gtkmm-4 from a single source tree. More...

#include <gtkmm/box.h>
#include <gtkmm/dialog.h>
#include <gtkmm/messagedialog.h>
#include <gtkmm/aboutdialog.h>
#include <gtkmm/label.h>
#include <gtkmm/filechooser.h>
#include <gtkmm/paned.h>
#include <gtkmm/scrolledwindow.h>
#include <gtkmm/window.h>
#include <gtkmm/cssprovider.h>
#include <gtkmm/stylecontext.h>
#include <gdkmm/display.h>
#include <gdkmm/monitor.h>
#include <gdkmm/rectangle.h>
#include <gtkmm/textbuffer.h>
#include <gdkmm/pixbuf.h>
#include <giomm/menu.h>
#include <giomm/inputstream.h>
#include <gtkmm/clipboard.h>
#include <gtkmm/selectiondata.h>
#include <gtkmm/targetentry.h>
#include <giomm/simpleactiongroup.h>
#include <gtkmm/menu.h>
#include <gtkmm/menuitem.h>
#include <gtkmm/gesturemultipress.h>
#include <gtkmm/widget.h>
#include <gtkmm/textview.h>
#include <gdkmm/types.h>
#include <giomm/application.h>
#include <pangomm/attributes.h>
#include <pangomm/tabarray.h>
#include <glibmm/main.h>
#include <glibmm/ustring.h>
#include <glibmm/value.h>
#include <type_traits>
#include <memory>
#include <functional>
#include <string>
#include <vector>

Go to the source code of this file.

Classes

class  cdb::ContextMenu
 A right-click context menu. More...
 

Namespaces

namespace  cdb
 
namespace  cdb::clipboard_detail
 

Typedefs

using cdb::ClickGesture = Gtk::GestureMultiPress
 Gtk::GestureMultiPress was renamed Gtk::GestureClick in GTK4, and the way a controller is attached to a widget changed: gtkmm-3 passes the widget to create(), GTK4 uses Gtk::Widget::add_controller().
 

Enumerations

enum class  cdb::Expand { cdb::no , cdb::yes }
 GTK4 dissolved pack_start's three arguments into properties on the child: expand became set_h/vexpand, fill became the h/valign (FILL is the default, and no live call site used PACK_EXPAND_PADDING), and per-child padding became margins. More...
 
enum class  cdb::AccessibleRole { cdb::math , cdb::text , cdb::push_button }
 Accessible roles we actually use. More...
 

Functions

Gtk::TextBuffer::iterator cdb::insert_image (const Glib::RefPtr< Gtk::TextBuffer > &buffer, const Gtk::TextBuffer::iterator &pos, const Glib::RefPtr< Gdk::Pixbuf > &pixbuf)
 GTK4 replaced Gtk::TextBuffer::insert_pixbuf() with insert_paintable(); a Gdk::Pixbuf has to be wrapped in a Gdk::Texture to become one.
 
void cdb::box_append (Gtk::Box &box, Gtk::Widget &child, Expand expand=Expand::no, int padding=0)
 
bool cdb::has_modifier (Gdk::ModifierType state, Gdk::ModifierType modifier)
 
Glib::RefPtr< ClickGesture > cdb::add_click_gesture (Gtk::Widget &widget)
 
std::string & cdb::clipboard_detail::text_payload ()
 
std::string & cdb::clipboard_detail::cadabra_payload ()
 
void cdb::clipboard_detail::on_get (Gtk::SelectionData &selection_data, guint)
 
void cdb::clipboard_detail::on_clear ()
 
void cdb::clipboard_set (Gtk::Widget &widget, const std::string &text, const std::string &cadabra)
 Put text on the clipboard, plus cadabra under the private target if it is non-empty.
 
void cdb::clipboard_read (Gtk::Widget &widget, bool primary, const std::function< void(const std::string &)> &on_received)
 Read the clipboard and hand the result to on_received.
 
template<typename T , typename U >
Glib::RefPtr< T > cdb::refptr_dynamic_cast (const Glib::RefPtr< U > &ptr)
 glibmm-2.68 made Glib::RefPtr an alias for std::shared_ptr, which dropped the static RefPtr<T>::cast_dynamic().
 
void cdb::window_centre_on_parent (Gtk::Window &window)
 Gtk::Window::set_position() is removed in GTK4, where placement is left to the compositor.
 
void cdb::label_set_wrap (Gtk::Label &label, bool wrap=true)
 Gtk::Label::set_line_wrap() is set_wrap() in GTK4.
 
void cdb::set_margin_all (Gtk::Widget &widget, int margin)
 GTK4 has no single "margin" property, only the four sides.
 
void cdb::widget_size_allocate (Gtk::Widget &widget, const Gtk::Allocation &allocation)
 GTK4 added a baseline argument to Gtk::Widget::size_allocate().
 
bool cdb::translate_widget_coords (Gtk::Widget &src, Gtk::Widget &dest, double src_x, double src_y, double &dest_x, double &dest_y)
 Position of a point in src's coordinate space, expressed in dest's.
 
int cdb::dialog_run (Gtk::Dialog &dialog)
 Show the about box and block until the user dismisses it.
 
void cdb::about_dialog_run (Gtk::AboutDialog &about)
 
void cdb::about_dialog_set_logo (Gtk::AboutDialog &about, const Glib::RefPtr< Gdk::Pixbuf > &logo)
 GTK4's Gtk::AboutDialog::set_logo() takes a Gdk::Paintable rather than a Gdk::Pixbuf.
 
template<typename T >
Glib::RefPtr< T > cdb::refptr_for_instance (T *object)
 Wrap a freshly-constructed Glib::Object subclass in a RefPtr.
 
bool cdb::css_load_from_data (const Glib::RefPtr< Gtk::CssProvider > &provider, const std::string &data)
 Gtk::CssProvider::load_from_data() returns bool on gtkmm-3 but void on GTK4, where a parse failure is reported through ::parsing-error instead.
 
unsigned int cdb::box_child_count (Gtk::Box &box)
 gtkmm-3's Gtk::Container API for inspecting and reordering children is gone in GTK4: there is no get_children(), and reorder_child(child, n) became reorder_child_after(child, sibling).
 
void cdb::box_reorder_child (Gtk::Box &box, Gtk::Widget &child, unsigned int index)
 Move child to absolute position index among box's children.
 
void cdb::scrolled_window_unset_child (Gtk::ScrolledWindow &sw)
 Detaching a child.
 
void cdb::paned_unset_end (Gtk::Paned &paned)
 
void cdb::show_now (Gtk::Widget &widget)
 Gtk::Widget::show_now() is removed in GTK4; there is no way (nor need) to force a synchronous map.
 
void cdb::file_chooser_confirm_overwrite (Gtk::FileChooser &chooser)
 GTK4 removed Gtk::FileChooser::set_do_overwrite_confirmation(): a save dialog there always confirms an overwrite.
 
void cdb::add_css_provider_for_default_display (const Glib::RefPtr< Gtk::CssProvider > &provider, guint priority)
 Gdk::Screen is gone in GTK4; style providers attach to a Gdk::Display.
 
Gdk::Rectangle cdb::monitor_geometry (Gtk::Window &window)
 The geometry of the monitor the window is on.
 
void cdb::set_dialog_type_hint (Gtk::Window &window)
 Gtk::Window::set_type_hint() is removed in GTK4; the window manager is told what a dialog is via its transient-for and modal state instead.
 
void cdb::paned_set_start (Gtk::Paned &paned, Gtk::Widget &child, bool resize, bool shrink)
 GTK4 replaced Gtk::Paned::pack1/pack2 with set_start_child/set_end_child plus separate resize/shrink setters.
 
void cdb::paned_set_end (Gtk::Paned &paned, Gtk::Widget &child, bool resize, bool shrink)
 
void cdb::show_all (Gtk::Widget &widget)
 GTK4 removed show_all().
 
template<typename Container >
void cdb::show_all_children (Container &container)
 As above, but the gtkmm-3 form that shows the descendants without showing the widget itself.
 
template<typename Parent >
void cdb::add_child (Parent &parent, Gtk::Widget &child)
 Put child inside parent.
 
void cdb::set_accessible_role (Gtk::Widget &w, AccessibleRole role)
 
void cdb::set_accessible_name (Gtk::Widget &w, const Glib::ustring &name)
 

Variables

constexpr auto cdb::APP_HANDLES_OPEN = Gio::APPLICATION_HANDLES_OPEN
 Unscoped gtkmm-3 enumerators became scoped enum classes in gtkmm-4, so the spellings differ even though the values do not.
 
constexpr auto cdb::APP_HANDLES_COMMAND_LINE = Gio::APPLICATION_HANDLES_COMMAND_LINE
 
constexpr auto cdb::APP_NON_UNIQUE = Gio::APPLICATION_NON_UNIQUE
 
constexpr auto cdb::OPTION_TYPE_BOOL = Gio::Application::OptionType::OPTION_TYPE_BOOL
 
constexpr auto cdb::OPTION_TYPE_INT = Gio::Application::OptionType::OPTION_TYPE_INT
 
constexpr auto cdb::OPTION_TYPE_STRING = Gio::Application::OptionType::OPTION_TYPE_STRING
 
constexpr auto cdb::ORIENT_HORIZONTAL = Gtk::ORIENTATION_HORIZONTAL
 
constexpr auto cdb::ORIENT_VERTICAL = Gtk::ORIENTATION_VERTICAL
 
constexpr auto cdb::ALIGN_FILL = Gtk::ALIGN_FILL
 
constexpr auto cdb::ALIGN_START = Gtk::ALIGN_START
 
constexpr auto cdb::ALIGN_END = Gtk::ALIGN_END
 
constexpr auto cdb::ALIGN_CENTER = Gtk::ALIGN_CENTER
 
constexpr auto cdb::POLICY_ALWAYS = Gtk::POLICY_ALWAYS
 
constexpr auto cdb::POLICY_AUTOMATIC = Gtk::POLICY_AUTOMATIC
 
constexpr auto cdb::POLICY_NEVER = Gtk::POLICY_NEVER
 
constexpr auto cdb::SIZE_REQUEST_HEIGHT_FOR_WIDTH = Gtk::SizeRequestMode::SIZE_REQUEST_HEIGHT_FOR_WIDTH
 
constexpr auto cdb::SIZE_REQUEST_WIDTH_FOR_HEIGHT = Gtk::SizeRequestMode::SIZE_REQUEST_WIDTH_FOR_HEIGHT
 
constexpr auto cdb::TEXT_WINDOW_TEXT = Gtk::TEXT_WINDOW_TEXT
 
constexpr auto cdb::WRAP_WORD_CHAR = Gtk::WRAP_WORD_CHAR
 
constexpr auto cdb::WRAP_NONE = Gtk::WRAP_NONE
 
constexpr auto cdb::COLORSPACE_RGB = Gdk::COLORSPACE_RGB
 
constexpr auto cdb::STATE_FLAG_NORMAL = Gtk::STATE_FLAG_NORMAL
 
constexpr auto cdb::STATE_FLAG_SELECTED = Gtk::STATE_FLAG_SELECTED
 
constexpr auto cdb::RESPONSE_OK = Gtk::RESPONSE_OK
 
constexpr auto cdb::RESPONSE_CANCEL = Gtk::RESPONSE_CANCEL
 
constexpr auto cdb::RESPONSE_CLOSE = Gtk::RESPONSE_CLOSE
 
constexpr auto cdb::RESPONSE_YES = Gtk::RESPONSE_YES
 
constexpr auto cdb::RESPONSE_APPLY = Gtk::RESPONSE_APPLY
 
constexpr auto cdb::MESSAGE_INFO = Gtk::MESSAGE_INFO
 
constexpr auto cdb::MESSAGE_WARNING = Gtk::MESSAGE_WARNING
 
constexpr auto cdb::MESSAGE_QUESTION = Gtk::MESSAGE_QUESTION
 
constexpr auto cdb::MESSAGE_ERROR = Gtk::MESSAGE_ERROR
 
constexpr auto cdb::BUTTONS_NONE = Gtk::BUTTONS_NONE
 
constexpr auto cdb::BUTTONS_OK = Gtk::BUTTONS_OK
 
constexpr auto cdb::BUTTONS_YES_NO = Gtk::BUTTONS_YES_NO
 
constexpr auto cdb::FILE_CHOOSER_ACTION_OPEN = Gtk::FILE_CHOOSER_ACTION_OPEN
 
constexpr auto cdb::FILE_CHOOSER_ACTION_SAVE = Gtk::FILE_CHOOSER_ACTION_SAVE
 
constexpr auto cdb::LICENSE_GPL_3_0 = Gtk::License::LICENSE_GPL_3_0
 
constexpr auto cdb::PANGO_TAB_LEFT = Pango::TAB_LEFT
 
constexpr auto cdb::PANGO_UNDERLINE_ERROR = Pango::Underline::UNDERLINE_ERROR
 
constexpr auto cdb::MODIFIER_SHIFT = Gdk::SHIFT_MASK
 Gdk::ModifierType became a scoped enum in GTK4, so both the enumerator spellings and the way a mask is tested differ.
 
constexpr auto cdb::MODIFIER_CONTROL = Gdk::CONTROL_MASK
 
constexpr auto cdb::SEQ_CLAIMED = Gtk::EVENT_SEQUENCE_CLAIMED
 
const char * cdb::CADABRA_CLIPBOARD_TARGET = "cadabra"
 Clipboard.
 

Detailed Description

Compatibility helpers that let the gtkmm frontend build against both gtkmm-3 and gtkmm-4 from a single source tree.

Everything lives in namespace cdb and is a thin inline wrapper, so that when support for gtkmm-3 is eventually dropped these can be inlined back into the call sites mechanically.

USE_GTK4 is set as a compile definition by frontend/gtkmm/CMakeLists.txt; it deliberately does not come from Config.hh, which is generated into the source tree and shared between build directories.