Horizon
pool_git_box.hpp
1 #pragma once
2 #include <gtkmm.h>
3 #include <set>
4 #include <mutex>
5 #include "util/uuid.hpp"
6 #include "common/common.hpp"
7 #include "nlohmann/json.hpp"
8 #include <git2.h>
9 
10 class git_repository;
11 
12 namespace horizon {
13 using json = nlohmann::json;
14 
15 class PoolGitBox : public Gtk::Box {
16 public:
17  PoolGitBox(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &x, class PoolNotebook *nb);
18  static PoolGitBox *create(class PoolNotebook *nb);
19 
20  void refresh();
21  bool refreshed_once = false;
22 
23 private:
24  class PoolNotebook *notebook = nullptr;
25 
26  Gtk::Button *refresh_button = nullptr;
27  Gtk::Label *info_label = nullptr;
28  Gtk::TreeView *diff_treeview = nullptr;
29  Gtk::TreeView *status_treeview = nullptr;
30  Gtk::CheckButton *diff_show_deleted_checkbutton = nullptr;
31  Gtk::CheckButton *diff_show_modified_checkbutton = nullptr;
32  Gtk::Box *diff_box = nullptr;
33 
34  void make_treeview(Gtk::TreeView *treeview);
35 
36  class TreeColumns : public Gtk::TreeModelColumnRecord {
37  public:
38  TreeColumns()
39  {
40  Gtk::TreeModelColumnRecord::add(name);
41  Gtk::TreeModelColumnRecord::add(type);
42  Gtk::TreeModelColumnRecord::add(uuid);
43 
44  Gtk::TreeModelColumnRecord::add(status);
45  Gtk::TreeModelColumnRecord::add(status_flags);
46  Gtk::TreeModelColumnRecord::add(path);
47  }
48  Gtk::TreeModelColumn<Glib::ustring> name;
49  Gtk::TreeModelColumn<ObjectType> type;
50  Gtk::TreeModelColumn<UUID> uuid;
51 
52  Gtk::TreeModelColumn<git_delta_t> status;
53  Gtk::TreeModelColumn<unsigned int> status_flags;
54  Gtk::TreeModelColumn<std::string> path;
55  };
56  TreeColumns list_columns;
57 
58  Glib::RefPtr<Gtk::ListStore> diff_store;
59  Glib::RefPtr<Gtk::TreeModelFilter> diff_store_filtered;
60 
61  Glib::RefPtr<Gtk::ListStore> status_store;
62 
63  static int diff_file_cb_c(const git_diff_delta *delta, float progress, void *pl);
64  static int status_cb_c(const char *path, unsigned int status_flags, void *payload);
65  void status_cb(const char *path, unsigned int status_flags);
66  void diff_file_cb(const git_diff_delta *delta);
67 
68  void update_store_from_db_prepare();
69  void update_store_from_db(Glib::RefPtr<Gtk::ListStore> store);
70 };
71 } // namespace horizon
nlohmann::json
basic_json<> json
default JSON class
Definition: json_fwd.hpp:61
horizon::PoolNotebook
Definition: pool_notebook.hpp:24
nlohmann::basic_json
a class to store JSON values
Definition: json.hpp:161
horizon::PoolGitBox
Definition: pool_git_box.hpp:15