4#include <gtkmm/window.h>
5#include <gtkmm/applicationwindow.h>
7#include <gtkmm/progressbar.h>
8#include <gtkmm/spinner.h>
9#include <gtkmm/label.h>
11#include <gtkmm/button.h>
12#include <gtkmm/builder.h>
13#include <gtkmm/cssprovider.h>
15#include <gtkmm/popovermenubar.h>
16#include <gtkmm/eventcontrollerkey.h>
18#include <gtkmm/menubar.h>
21#include <glibmm/dispatcher.h>
22#include <giomm/settings.h>
23#include <giomm/actiongroup.h>
28#include "nlohmann/json.hpp"
35#include "../common/TeXEngine.hh"
54 virtual void add_cell(
const DTree&, DTree::iterator,
bool)
override;
296 std::string
save(
const std::string&
fn)
const;
363#if GTKMM_MAJOR_VERSION>3 || (GTKMM_MAJOR_VERSION==3 && GTKMM_MINOR_VERSION>=10)
int quit(void *)
Definition Server.cc:328
The Cadabra notebook application.
Definition Cadabra.hh:12
Base class which talks to the server and sends Action objects back to the DocumentThread.
Definition ComputeThread.hh:42
Definition DataCell.hh:116
A base class with all the logic to manipulate a Cadabra notebook document.
Definition DocumentThread.hh:41
ComputeThread * compute
Definition DocumentThread.hh:159
Abstract base class with methods that need to be implemented by any GUI.
Definition GUIBase.hh:16
Each notebook has one main window which controls it.
Definition NotebookWindow.hh:47
void on_file_quit()
Definition NotebookWindow.cc:2605
virtual void load_from_string(const std::string ¬ebook_contents) override
Load a new notebook from a JSON string.
Definition NotebookWindow.cc:2317
void on_view_split()
Definition NotebookWindow.cc:2787
bool kernel_spinner_status
Definition NotebookWindow.hh:205
virtual void process_data() override
When the ComputeThread needs to modify the document, it stores an ActionBase object on the stack (see...
Definition NotebookWindow.cc:1199
virtual void set_compute_thread(ComputeThread *compute) override
Let the notebook know about the ComputeThread so that it can send cells for evaluation.
Definition NotebookWindow.cc:2902
bool cell_content_erase(int, int, DTree::iterator, int)
Definition NotebookWindow.cc:2115
Gtk::Box mainbox
Definition NotebookWindow.hh:181
std::unique_ptr< DiffViewer > diffviewer
Definition NotebookWindow.hh:192
bool on_copy_as_latex(const DTree::iterator it)
Definition NotebookWindow.cc:2222
Gtk::Label kernel_label
Definition NotebookWindow.hh:206
Glib::RefPtr< Gio::SimpleAction > action_fontsize
Definition NotebookWindow.hh:358
virtual void set_progress(const std::string &msg, int cur_step, int total_steps) override
Definition NotebookWindow.cc:1646
std::string progress_string
Definition NotebookWindow.hh:213
void on_tools_options()
Definition NotebookWindow.cc:3381
void on_file_export_html()
Definition NotebookWindow.cc:2442
virtual void on_connect() override
Network status is propagated from the ComputeThread to the GUI using the following methods.
Definition NotebookWindow.cc:1206
bool on_scroll_changed()
Definition NotebookWindow.cc:2005
void propagate_global_hide_flag()
Definition NotebookWindow.cc:3265
double display_scale
Definition NotebookWindow.hh:77
Glib::RefPtr< Gtk::CssProvider > css_provider
Definition NotebookWindow.hh:341
bool handle_key_press(guint keyval, Gdk::ModifierType state)
Window-level handlers shared between the toolkits.
Definition NotebookWindow.cc:1323
void on_edit_copy(const Glib::VariantBase &)
Definition NotebookWindow.cc:2623
void compare_to_file()
Definition NotebookWindow.cc:3050
Glib::Dispatcher dispatch_update_status
Definition NotebookWindow.hh:220
virtual bool on_configure_event(GdkEventConfigure *cfg) override
Definition NotebookWindow.cc:1127
void on_crash_window_closed(int)
Definition NotebookWindow.cc:1314
void on_prefs_choose_colours()
Definition NotebookWindow.cc:3358
int status_col
Definition NotebookWindow.hh:215
void on_run_cell()
Definition NotebookWindow.cc:2808
void on_search_text_changed()
Search handling.
Definition NotebookWindow.cc:2712
int last_configure_width
Definition NotebookWindow.hh:345
void select_range(const DTree &, DTree::iterator, int start, int len)
Definition NotebookWindow.cc:1875
void process_todo_queue()
Todo deque processing logic.
Definition NotebookWindow.cc:1262
void on_edit_undo(const Glib::VariantBase &)
Definition NotebookWindow.cc:2613
void on_prefs_hide_input_cells(const Glib::VariantBase &vb)
Definition NotebookWindow.cc:3248
virtual void remove_cell(const DTree &, DTree::iterator) override
Remove a single cell together with all its child cells.
Definition NotebookWindow.cc:1680
double progress_frac
Definition NotebookWindow.hh:214
virtual size_t get_cursor_position(const DTree &, DTree::iterator) override
Retrieve the position of the cursor in the current cell.
Definition NotebookWindow.cc:1897
Gtk::Button tool_restart
Definition NotebookWindow.hh:178
Glib::RefPtr< Gio::SimpleActionGroup > actiongroup
Definition NotebookWindow.hh:172
void compare_git_latest()
Definition NotebookWindow.cc:3122
Glib::Dispatcher dispatcher
Definition NotebookWindow.hh:164
virtual bool on_unhandled_error(const std::exception &err) override
Definition NotebookWindow.cc:1143
void interactive_execute()
Definition NotebookWindow.cc:2156
void on_edit_find()
Definition NotebookWindow.cc:2704
void handle_width_change(int width)
Re-layout the cells when the window width changes.
Definition NotebookWindow.cc:1107
Gtk::Box toolbar
Definition NotebookWindow.hh:176
std::string kernel_string
Definition NotebookWindow.hh:213
Glib::RefPtr< Gio::SimpleAction > action_undo
Definition NotebookWindow.hh:357
bool read_only
Definition NotebookWindow.hh:235
DTree::iterator selected_cell
Definition NotebookWindow.hh:145
Gtk::Button tool_run
Definition NotebookWindow.hh:178
Glib::RefPtr< Gio::SimpleAction > action_paste
Definition NotebookWindow.hh:358
Gtk::Label status_label
Definition NotebookWindow.hh:206
Glib::RefPtr< Gio::SimpleAction > action_hide_input_cells
Definition NotebookWindow.hh:359
void on_edit_paste()
Definition NotebookWindow.cc:2634
void on_realize() override
Definition NotebookWindow.cc:80
void on_file_export_python()
Definition NotebookWindow.cc:2491
std::mutex status_mutex
Definition NotebookWindow.hh:212
Gtk::Label top_label
Definition NotebookWindow.hh:206
Gtk::SearchBar searchbar
Definition NotebookWindow.hh:182
void refresh_highlighting()
Definition NotebookWindow.cc:3487
std::string last_find_string
Definition NotebookWindow.hh:350
Gtk::ProgressBar progressbar
Definition NotebookWindow.hh:203
Gtk::CheckButton search_case_insensitive
Definition NotebookWindow.hh:185
void on_help_about()
Definition NotebookWindow.cc:2907
virtual void dim_output_cells(DTree::iterator it) override
Dim all output cells of the visual cells corresponding to the given document cell.
Definition NotebookWindow.cc:2128
Cadabra * cdbapp
The application object, owned by main() for the lifetime of the process; this is a borrowed pointer,...
Definition NotebookWindow.hh:156
void resize_codeinput_texview_all(int width)
Definition NotebookWindow.cc:1039
Gtk::Label search_result
Definition NotebookWindow.hh:186
void on_edit_insert_below()
Definition NotebookWindow.cc:2666
void on_edit_insert_above()
Definition NotebookWindow.cc:2650
void on_prefs_use_defaults()
Definition NotebookWindow.cc:3365
std::string run_git_command(const std::string &args)
Definition NotebookWindow.cc:3077
void on_help() const
Definition NotebookWindow.cc:2869
void on_edit_split()
Definition NotebookWindow.cc:2749
virtual bool on_key_press_event(GdkEventKey *) override
Definition NotebookWindow.cc:1388
std::string clipboard_cdb
Definition NotebookWindow.hh:293
void on_help_register()
Definition NotebookWindow.cc:2938
Gtk::Button tool_restart_and_run_all
Definition NotebookWindow.hh:178
void update_title()
Definition NotebookWindow.cc:1155
Gtk::Button tool_stop
Definition NotebookWindow.hh:178
void on_scroll_size_allocated()
Definition NotebookWindow.cc:2018
std::vector< Glib::RefPtr< Gio::SimpleAction > > default_actions
Definition NotebookWindow.hh:158
void on_edit_delete()
Definition NotebookWindow.cc:2684
void on_outbox_copy(DTree::iterator it)
Definition NotebookWindow.cc:3545
bool is_configured
Definition NotebookWindow.hh:352
void on_edit_redo(const Glib::VariantBase &)
Definition NotebookWindow.cc:2618
Gtk::Paned dragbox
Definition NotebookWindow.hh:180
std::string clipboard_txt
Clipboard handling.
Definition NotebookWindow.hh:293
void on_prefs_highlight_syntax(bool on)
Definition NotebookWindow.cc:3326
Gtk::Box supermainbox
Definition NotebookWindow.hh:179
void on_file_save_as_jupyter()
Definition NotebookWindow.cc:2409
virtual void position_cursor(const DTree &, DTree::iterator, int pos) override
Position the cursor in the current canvas in the widget corresponding to the indicated cell.
Definition NotebookWindow.cc:1830
Glib::RefPtr< Gio::SimpleAction > action_copy
Definition NotebookWindow.hh:357
bool on_first_redraw()
Definition NotebookWindow.cc:2338
void set_stop_sensitive(bool)
Definition NotebookWindow.cc:1191
void unselect_output_cell()
Definition NotebookWindow.cc:3506
void scroll_cell_into_view(DTree::iterator cell)
Definition NotebookWindow.cc:1918
void on_file_export_latex()
Definition NotebookWindow.cc:2463
void on_run_stop()
Definition NotebookWindow.cc:2838
double scale
Definition NotebookWindow.hh:76
void on_prefs_font_size(int num)
Definition NotebookWindow.cc:3290
std::pair< DTree::iterator, size_t > last_find_location
Definition NotebookWindow.hh:349
void select_git_path()
Functionality for the diff viewer.
Definition NotebookWindow.cc:3040
void on_text_scaling_factor_changed(const std::string &key)
Definition NotebookWindow.cc:3019
bool crash_window_hidden
Definition NotebookWindow.hh:312
std::vector< NotebookCanvas * > canvasses
Definition NotebookWindow.hh:196
virtual void on_disconnect(const std::string &) override
Definition NotebookWindow.cc:1231
bool cell_complete_request(DTree::iterator it, int pos, int i)
Definition NotebookWindow.cc:2163
void on_ignore_cell_on_import()
Definition NotebookWindow.cc:2767
void on_prefs_auto_close_latex(const Glib::VariantBase &vb)
Definition NotebookWindow.cc:3236
virtual void on_interactive_output(const nlohmann::json &msg) override
Definition NotebookWindow.cc:1641
void on_file_new()
Definition NotebookWindow.cc:2251
void refresh_after_tex_engine_run()
Refresh the display after a TeX engine run has completed.
Definition NotebookWindow.cc:1137
Glib::RefPtr< Gio::SimpleAction > action_redo
Definition NotebookWindow.hh:357
bool quit_safeguard(bool quit)
Definition NotebookWindow.cc:2567
virtual void on_network_error() override
Definition NotebookWindow.cc:1239
virtual bool on_delete_event(GdkEventAny *) override
Definition NotebookWindow.cc:988
TeXEngine engine
Definition NotebookWindow.hh:75
void on_edit_cell_is_python()
Definition NotebookWindow.cc:2756
Glib::RefPtr< Gio::SimpleAction > action_console
Definition NotebookWindow.hh:360
std::string save(const std::string &fn) const
Definition NotebookWindow.cc:2542
void on_kernel_restart()
Definition NotebookWindow.cc:2844
bool handle_close_request()
Returns true to block the close, matching GTK4's ::close-request.
Definition NotebookWindow.cc:978
bool run_all_after_restart
Definition NotebookWindow.hh:353
void on_prefs_set_cv(int vis)
Definition NotebookWindow.cc:996
Glib::RefPtr< Gtk::Builder > uimanager
Definition NotebookWindow.hh:173
void on_file_save()
Definition NotebookWindow.cc:2349
void scroll_current_cell_into_view()
Definition NotebookWindow.cc:1910
Gtk::Button tool_save_as
Definition NotebookWindow.hh:177
void on_run_runtocursor()
Definition NotebookWindow.cc:2821
Gtk::Button tool_run_to
Definition NotebookWindow.hh:178
void on_file_save_as()
Definition NotebookWindow.cc:2372
void on_kernel_restart_and_run_all()
Definition NotebookWindow.cc:2862
bool idle_handler()
Definition NotebookWindow.cc:3495
Gtk::Button tool_save
Definition NotebookWindow.hh:177
void compare_git_choose()
Definition NotebookWindow.cc:3154
void set_title_prefix(const std::string &)
Definition NotebookWindow.cc:1150
bool cell_got_focus(DTree::iterator, int)
Definition NotebookWindow.cc:2145
bool on_tex_error(const std::string &, DTree::iterator)
Definition NotebookWindow.cc:2228
Gtk::SearchEntry searchentry
Definition NotebookWindow.hh:184
bool modified
Definition NotebookWindow.hh:235
void update_status()
Definition NotebookWindow.cc:1662
Gtk::Dialog console_win
Definition NotebookWindow.hh:190
void on_edit_cell_is_latex()
Definition NotebookWindow.cc:2776
bool cell_toggle_visibility(DTree::iterator it, int)
Definition NotebookWindow.cc:2035
Glib::RefPtr< Gio::SimpleAction > action_highlight
Definition NotebookWindow.hh:358
void on_view_close(const Glib::VariantBase &)
Definition NotebookWindow.cc:2797
Console console
Definition NotebookWindow.hh:189
int status_line
Definition NotebookWindow.hh:215
Glib::RefPtr< Gio::SimpleAction > action_stop
Definition NotebookWindow.hh:360
void on_tools_clear_cache()
Definition NotebookWindow.cc:3469
Gtk::Box search_hbox
Definition NotebookWindow.hh:183
void compare_git_specific()
Definition NotebookWindow.cc:3209
virtual void update_cell(const DTree &, DTree::iterator) override
The basic manipulations that a GUI needs to implement are adding, removing and updating (refreshing t...
Definition NotebookWindow.cc:1789
std::string name
Definition NotebookWindow.hh:234
void on_slider_changed(std::string variable, double value)
Definition NotebookWindow.cc:2012
void set_statusbar_message(const std::string &message="", int line=-1, int col=-1)
Definition NotebookWindow.cc:1180
bool cell_content_execute(DTree::iterator, bool shift_enter_pressed)
Definition NotebookWindow.cc:2182
virtual void add_cell(const DTree &, DTree::iterator, bool) override
Add a GUI cell corresponding to the document cell at the iterator.
Definition NotebookWindow.cc:1396
bool cell_content_changed(DTree::iterator it, int i)
Definition NotebookWindow.cc:2092
~NotebookWindow()
Definition NotebookWindow.cc:878
Gtk::Button tool_open
Definition NotebookWindow.hh:177
void handle_outbox_select(DTree::iterator it)
Definition NotebookWindow.cc:3521
std::string geometry_string
Definition NotebookWindow.hh:234
void compare_git(const std::string &commit_hash)
Definition NotebookWindow.cc:3104
void on_file_open()
Definition NotebookWindow.cc:2278
std::string status_string
Definition NotebookWindow.hh:213
virtual void on_kernel_runstatus(bool) override
Definition NotebookWindow.cc:1246
void on_file_export_html_segment()
Definition NotebookWindow.cc:2515
Glib::Dispatcher dispatch_refresh
Definition NotebookWindow.hh:220
Gtk::Spinner kernel_spinner
Definition NotebookWindow.hh:204
Glib::RefPtr< Gio::Settings > settings
Definition NotebookWindow.hh:342
virtual void hide_visual_cells(DTree::iterator it) override
Hide all visual cells (on all canvasses) corresponding to a given document cell.
Definition NotebookWindow.cc:2208
Gtk::Box statusbarbox
Definition NotebookWindow.hh:187
void on_file_close()
Definition NotebookWindow.cc:2264
Glib::RefPtr< Gio::SimpleAction > action_view_close
Definition NotebookWindow.hh:358
bool cell_content_insert(const std::string &, int, DTree::iterator, int)
Definition NotebookWindow.cc:2103
void load_css()
Definition NotebookWindow.cc:882
int current_canvas
Definition NotebookWindow.hh:197
Glib::RefPtr< Gio::SimpleAction > action_auto_close_latex
Definition NotebookWindow.hh:359
std::string title_prefix
Definition NotebookWindow.hh:234
void set_name(const std::string &)
Definition NotebookWindow.cc:2311
void resize_codeinput_texview(DTree::iterator, int width)
Definition NotebookWindow.cc:1052
Glib::RefPtr< Gio::SimpleAction > action_register
Definition NotebookWindow.hh:360
virtual void remove_all_cells() override
Remove all GUI cells from the display (used as a quick way to clear all before loading a new document...
Definition NotebookWindow.cc:1770
Gtk::Box topbox
Definition NotebookWindow.hh:175
TeXEngine is used to convert LaTeX strings into PNG images.
Definition TeXEngine.hh:23
Functions to handle the exchange properties of two or more symbols in a product.
Definition Adjform.cc:83
void set(rset_t::iterator &num, multiplier_t fac)
Definition Storage.cc:1180