1 // SPDX-License-Identifier: GPL-2.0-or-later 2 3 #ifndef INKSCAPE_UI_DIALOG_NOTEBOOK_H 4 #define INKSCAPE_UI_DIALOG_NOTEBOOK_H 5 6 /** @file 7 * @brief A wrapper for Gtk::Notebook. 8 * 9 * Authors: see git history 10 * Tavmjong Bah 11 * 12 * Copyright (c) 2018 Tavmjong Bah, Authors 13 * 14 * Released under GNU GPL v2+, read the file 'COPYING' for more information. 15 */ 16 17 #include <gdkmm/dragcontext.h> 18 #include <gtkmm/menu.h> 19 #include <gtkmm/notebook.h> 20 #include <gtkmm/radiomenuitem.h> 21 #include <gtkmm/scrolledwindow.h> 22 #include <gtkmm/widget.h> 23 24 namespace Inkscape { 25 namespace UI { 26 namespace Dialog { 27 28 class DialogContainer; 29 class DialogWindow; 30 31 /** 32 * A widget that wraps a Gtk::Notebook with dialogs as pages. 33 * 34 * A notebook is fixed to a specific DialogContainer which manages the dialogs inside the notebook. 35 */ 36 class DialogNotebook : public Gtk::ScrolledWindow 37 { 38 public: 39 DialogNotebook(DialogContainer *container); 40 ~DialogNotebook() override; 41 42 void add_page(Gtk::Widget &page, Gtk::Widget &tab, Glib::ustring label); 43 void move_page(Gtk::Widget &page); 44 45 // Getters get_notebook()46 Gtk::Notebook *get_notebook() { return &_notebook; } get_container()47 DialogContainer *get_container() { return _container; } 48 49 // Notebook callbacks 50 void close_tab_callback(); 51 void close_notebook_callback(); 52 DialogWindow* pop_tab_callback(); 53 54 private: 55 // Widgets 56 DialogContainer *_container; 57 Gtk::Menu _menu; 58 Gtk::Notebook _notebook; 59 Gtk::RadioMenuItem _labels_auto_button; 60 61 // State variables 62 bool _labels_auto; 63 bool _label_visible; 64 bool _detaching_duplicate; 65 Gtk::Widget *_selected_page; 66 std::vector<sigc::connection> _conn; 67 std::multimap<Gtk::Widget *, sigc::connection> _tab_connections; 68 69 // Signal handlers - notebook 70 void on_drag_end(const Glib::RefPtr<Gdk::DragContext> context); 71 void on_page_added(Gtk::Widget *page, int page_num); 72 void on_page_removed(Gtk::Widget *page, int page_num); 73 void on_size_allocate_scroll(Gtk::Allocation &allocation); 74 void on_size_allocate_notebook(Gtk::Allocation &allocation); 75 void on_labels_toggled(); 76 bool on_tab_click_event(GdkEventButton *event, Gtk::Widget *page); 77 void on_close_button_click_event(Gtk::Widget *page); 78 void on_page_switch(Gtk::Widget *page, guint page_number); 79 80 // Helpers 81 void toggle_tab_labels_callback(bool show); 82 void add_close_tab_callback(Gtk::Widget *page); 83 void remove_close_tab_callback(Gtk::Widget *page); 84 }; 85 86 } // namespace Dialog 87 } // namespace UI 88 } // namespace Inkscape 89 90 #endif // INKSCAPE_UI_DIALOG_NOTEBOOK_H 91 92 /* 93 Local Variables: 94 mode:c++ 95 c-file-style:"stroustrup" 96 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) 97 indent-tabs-mode:nil 98 fill-column:99 99 End: 100 */ 101 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : 102