1 #ifndef MAINWINDOW_H 2 #define MAINWINDOW_H 3 4 #include "config.h" 5 6 #include <gtkmm.h> 7 8 #include <json/json.h> 9 10 #include "notebook.h" 11 #include "navigation.h" 12 13 enum { 14 WND_ACTION_COLOR, 15 WND_ACTION_NEXT_NOTE, 16 WND_ACTION_PREV_NOTE, 17 WND_ACTION_TOGGLE_SIDEBAR, 18 WND_ACTION_TOGGLE_MARKDOWN_RENDERING 19 }; 20 21 int mkdirp(std::string dir); 22 23 class CMainWindow : public Gtk::ApplicationWindow 24 { 25 public: 26 CMainWindow(const Glib::RefPtr<Gtk::Application> &); 27 virtual ~CMainWindow(); 28 29 std::string active_document; 30 std::string selected_document; 31 32 sigc::connection close_handler; 33 34 void HardClose(); 35 void FetchAndSave(); 36 void OpenDocument(std::string filename); 37 void SetActiveFilename(std::string filename); 38 39 void FetchAndExport(); 40 41 void FocusDocument(); 42 43 void GetColor(int id, float &r, float &g, float &b); 44 void SetColor(int id, float r, float g, float b); 45 protected: 46 //Signal handlers: 47 bool on_close(GdkEventAny* any_event); 48 void on_action(std::string name,int type, int param); 49 bool on_click_color(GdkEventButton *btn, int num); 50 bool on_motion_notify(GdkEventMotion* event); 51 52 sigc::connection idle_timer; 53 bool on_idle(); 54 55 Gtk::HBox split; 56 //Gtk::Box filler; 57 58 /* config */ 59 std::string config_path; 60 std::string default_base_path; 61 std::string data_path; 62 void CalculatePaths(); 63 Json::Value config; 64 void LoadConfig(); 65 void SaveConfig(); 66 void RunConfigWindow(); 67 68 /* tree view on the left */ 69 Gtk::ScrolledWindow nav_scroll; 70 Gtk::TreeView nav; 71 CNavigationView nav_model; 72 73 /* document view */ 74 Gtk::ScrolledWindow sview_scroll; 75 CNotebook sview; 76 Glib::RefPtr<Gsv::Buffer> sbuffer; 77 Glib::RefPtr<Gdk::Cursor> pen_cursor, text_cursor, eraser_cursor, selection_cursor; 78 79 /* tool palette */ 80 Glib::RefPtr<Gtk::Builder> toolbar_builder; 81 Glib::RefPtr<Gtk::CssProvider> toolbar_style; 82 Gtk::Toolbar *toolbar; 83 void InitToolbar(); 84 void UpdateToolbarColors(); 85 86 /* header */ 87 bool use_hbar; 88 Gtk::HeaderBar hbar; 89 Gtk::MenuButton appbutton; 90 91 /* menu */ 92 Gtk::Menu appmenu; 93 struct { 94 Gtk::MenuItem prefs; 95 Gtk::SeparatorMenuItem sep; 96 Gtk::CheckMenuItem hide_sidebar; 97 Gtk::CheckMenuItem render_markdown; 98 Gtk::MenuItem exprt; 99 } am; 100 101 /* classic menu */ 102 struct { 103 Gtk::VBox menu_box; 104 Gtk::MenuBar mbar; 105 Gtk::MenuItem view; 106 } cm; 107 }; 108 109 #endif // MAINWINDOW_H