This repository was archived by the owner on Jun 25, 2020. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathdirectories.h
More file actions
93 lines (78 loc) · 2.73 KB
/
Copy pathdirectories.h
File metadata and controls
93 lines (78 loc) · 2.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#pragma once
#include <gtkmm.h>
#include <vector>
#include <string>
#include "boost/filesystem.hpp"
#include <thread>
#include <mutex>
#include <atomic>
#include <unordered_map>
#include <unordered_set>
#include "git.h"
#include "dispatcher.h"
class Directories : public Gtk::ListViewText {
class DirectoryData {
public:
Gtk::TreeModel::Row row;
Glib::RefPtr<Gio::FileMonitor> monitor;
std::shared_ptr<Git::Repository> repository;
std::shared_ptr<sigc::connection> 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<std::string> id;
Gtk::TreeModelColumn<std::string> name;
Gtk::TreeModelColumn<Glib::ustring> markup;
Gtk::TreeModelColumn<boost::filesystem::path> path;
Gtk::TreeModelColumn<PathType> type;
};
static Glib::RefPtr<TreeStore> create() {return Glib::RefPtr<TreeStore>(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<Gtk::TreeStore> tree_store;
TreeStore::ColumnRecord column_record;
std::unordered_map<std::string, DirectoryData> 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;
};