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 "util/sqlite.hpp"
9 #include <git2.h>
10 #include "util/sort_controller.hpp"
11 #include "rules/rules.hpp"
12 
13 namespace horizon {
14 using json = nlohmann::json;
15 
16 class PoolGitBox : public Gtk::Box {
17 public:
18  PoolGitBox(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &x, class PoolNotebook &nb);
19  static PoolGitBox *create(class PoolNotebook &nb);
20 
21  void refresh();
22  bool refreshed_once = false;
23 
24 private:
25  class PoolNotebook &notebook;
26 
27  Gtk::Button *refresh_button = nullptr;
28  Gtk::Label *info_label = nullptr;
29  Gtk::TreeView *diff_treeview = nullptr;
30  Gtk::TreeView *status_treeview = nullptr;
31  Gtk::CheckButton *diff_show_deleted_checkbutton = nullptr;
32  Gtk::CheckButton *diff_show_modified_checkbutton = nullptr;
33  Gtk::Box *diff_box = nullptr;
34  Gtk::Button *add_with_deps_button = nullptr;
35 
36  Gtk::Button *pr_button = nullptr;
37  Gtk::Button *back_to_master_button = nullptr;
38  Gtk::Button *back_to_master_delete_button = nullptr;
39 
40  void make_treeview(Gtk::TreeView *treeview);
41 
42  class TreeColumns : public Gtk::TreeModelColumnRecord {
43  public:
44  TreeColumns()
45  {
46  Gtk::TreeModelColumnRecord::add(name);
47  Gtk::TreeModelColumnRecord::add(type);
48  Gtk::TreeModelColumnRecord::add(uuid);
49 
50  Gtk::TreeModelColumnRecord::add(status);
51  Gtk::TreeModelColumnRecord::add(path);
52  Gtk::TreeModelColumnRecord::add(check_result);
53  }
54  Gtk::TreeModelColumn<Glib::ustring> name;
55  Gtk::TreeModelColumn<ObjectType> type;
56  Gtk::TreeModelColumn<UUID> uuid;
57 
58  Gtk::TreeModelColumn<unsigned int> status;
59  Gtk::TreeModelColumn<std::string> path;
60  Gtk::TreeModelColumn<RulesCheckResult> check_result;
61  };
62  TreeColumns list_columns;
63 
64  Glib::RefPtr<Gtk::ListStore> diff_store;
65  Glib::RefPtr<Gtk::ListStore> status_store;
66 
67  std::optional<SQLite::Query> q_diff;
68  std::optional<SQLite::Query> q_status;
69 
70  std::optional<SortController> sort_controller_diff;
71  std::optional<SortController> sort_controller_status;
72 
73  void update_diff();
74  void update_status();
75 
76  enum class View { DIFF, STATUS };
77 
78  void store_from_db(View view, const std::string &extra_q = "");
79 
80  static int diff_file_cb_c(const git_diff_delta *delta, float progress, void *pl);
81  static int status_cb_c(const char *path, unsigned int status_flags, void *payload);
82  void status_cb(const char *path, unsigned int status_flags);
83  void diff_file_cb(const git_diff_delta *delta);
84 
85  void handle_add_with_deps();
86  void handle_pr();
87  void handle_back_to_master(bool delete_pr);
88 };
89 } // namespace horizon
Definition: pool_git_box.hpp:16
Definition: pool_notebook.hpp:20
a class to store JSON values
Definition: json.hpp:177
basic_json<> json
default JSON class
Definition: json_fwd.hpp:62