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  Gtk::Button *add_with_deps_button = nullptr;
34 
35  Gtk::Button *pr_button = nullptr;
36  Gtk::Button *back_to_master_button = nullptr;
37  Gtk::Button *back_to_master_delete_button = nullptr;
38 
39  void make_treeview(Gtk::TreeView *treeview);
40 
41  class TreeColumns : public Gtk::TreeModelColumnRecord {
42  public:
43  TreeColumns()
44  {
45  Gtk::TreeModelColumnRecord::add(name);
46  Gtk::TreeModelColumnRecord::add(type);
47  Gtk::TreeModelColumnRecord::add(uuid);
48 
49  Gtk::TreeModelColumnRecord::add(status);
50  Gtk::TreeModelColumnRecord::add(status_flags);
51  Gtk::TreeModelColumnRecord::add(path);
52  }
53  Gtk::TreeModelColumn<Glib::ustring> name;
54  Gtk::TreeModelColumn<ObjectType> type;
55  Gtk::TreeModelColumn<UUID> uuid;
56 
57  Gtk::TreeModelColumn<git_delta_t> status;
58  Gtk::TreeModelColumn<unsigned int> status_flags;
59  Gtk::TreeModelColumn<std::string> path;
60  };
61  TreeColumns list_columns;
62 
63  Glib::RefPtr<Gtk::ListStore> diff_store;
64  Glib::RefPtr<Gtk::TreeModelFilter> diff_store_filtered;
65  Glib::RefPtr<Gtk::TreeModelSort> diff_store_sorted;
66 
67  Glib::RefPtr<Gtk::ListStore> status_store;
68  Glib::RefPtr<Gtk::TreeModelSort> status_store_sorted;
69  void install_sort(Glib::RefPtr<Gtk::TreeSortable> store);
70 
71  static int diff_file_cb_c(const git_diff_delta *delta, float progress, void *pl);
72  static int status_cb_c(const char *path, unsigned int status_flags, void *payload);
73  void status_cb(const char *path, unsigned int status_flags);
74  void diff_file_cb(const git_diff_delta *delta);
75 
76  void update_store_from_db_prepare();
77  void update_store_from_db(Glib::RefPtr<Gtk::ListStore> store);
78  void handle_add_with_deps();
79  void handle_pr();
80  void handle_back_to_master(bool delete_pr);
81 };
82 } // namespace horizon
nlohmann::basic_json
a class to store JSON values
Definition: json.hpp:166
nlohmann::json
basic_json<> json
default JSON class
Definition: json_fwd.hpp:61