#pragma once #include #include #include #include "boost/filesystem.hpp" #include #include #include #include #include #include "git.h" #include "dispatcher.h" class Directories : public Gtk::ListViewText { class DirectoryData { public: Gtk::TreeModel::Row row; Glib::RefPtr monitor; std::shared_ptr repository; std::shared_ptr connection; }; enum class PathType {KNOWN, UNKNOWN}; class TreeStore : public Gtk::TreeStore { protected: TreeStore()=default; bool row_drop_possible_vfunc(const Gtk::TreeModel::Path &path, const Gtk::SelectionData &selection_data) const override; bool drag_data_received_vfunc(const TreeModel::Path &path, const Gtk::SelectionData &selection_data) override; bool drag_data_delete_vfunc (const Gtk::TreeModel::Path &path) override; public: class ColumnRecord : public Gtk::TreeModel::ColumnRecord { public: ColumnRecord() { add(id); add(name); add(markup); add(path); add(type); } Gtk::TreeModelColumn id; Gtk::TreeModelColumn name; Gtk::TreeModelColumn markup; Gtk::TreeModelColumn path; Gtk::TreeModelColumn type; }; static Glib::RefPtr create() {return Glib::RefPtr(new TreeStore());} }; Directories(); public: static Directories &get() { static Directories singleton; return singleton; } ~Directories() override; void open(const boost::filesystem::path &dir_path=""); void update(); void on_save_file(const boost::filesystem::path &file_path); void select(const boost::filesystem::path &path); boost::filesystem::path path; protected: bool on_button_press_event(GdkEventButton *event) override; private: void add_or_update_path(const boost::filesystem::path &dir_path, const Gtk::TreeModel::Row &row, bool include_parent_paths); void remove_path(const boost::filesystem::path &dir_path); void colorize_path(boost::filesystem::path dir_path_, bool include_parent_paths); Glib::RefPtr tree_store; TreeStore::ColumnRecord column_record; std::unordered_map directories; Dispatcher dispatcher; Gtk::Menu menu; Gtk::MenuItem menu_item_new_file; Gtk::MenuItem menu_item_new_folder; Gtk::SeparatorMenuItem menu_item_separator; Gtk::MenuItem menu_item_rename; Gtk::MenuItem menu_item_delete; Gtk::Menu menu_root; Gtk::MenuItem menu_root_item_new_file; Gtk::MenuItem menu_root_item_new_folder; boost::filesystem::path menu_popup_row_path; };