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  void make_treeview(Gtk::TreeView *treeview);
36 
37  class TreeColumns : public Gtk::TreeModelColumnRecord {
38  public:
39  TreeColumns()
40  {
41  Gtk::TreeModelColumnRecord::add(name);
42  Gtk::TreeModelColumnRecord::add(type);
43  Gtk::TreeModelColumnRecord::add(uuid);
44 
45  Gtk::TreeModelColumnRecord::add(status);
46  Gtk::TreeModelColumnRecord::add(status_flags);
47  Gtk::TreeModelColumnRecord::add(path);
48  }
49  Gtk::TreeModelColumn<Glib::ustring> name;
50  Gtk::TreeModelColumn<ObjectType> type;
51  Gtk::TreeModelColumn<UUID> uuid;
52 
53  Gtk::TreeModelColumn<git_delta_t> status;
54  Gtk::TreeModelColumn<unsigned int> status_flags;
55  Gtk::TreeModelColumn<std::string> path;
56  };
57  TreeColumns list_columns;
58 
59  Glib::RefPtr<Gtk::ListStore> diff_store;
60  Glib::RefPtr<Gtk::TreeModelFilter> diff_store_filtered;
61  Glib::RefPtr<Gtk::TreeModelSort> diff_store_sorted;
62 
63  Glib::RefPtr<Gtk::ListStore> status_store;
64  Glib::RefPtr<Gtk::TreeModelSort> status_store_sorted;
65  void install_sort(Glib::RefPtr<Gtk::TreeSortable> store);
66 
67  static int diff_file_cb_c(const git_diff_delta *delta, float progress, void *pl);
68  static int status_cb_c(const char *path, unsigned int status_flags, void *payload);
69  void status_cb(const char *path, unsigned int status_flags);
70  void diff_file_cb(const git_diff_delta *delta);
71 
72  void update_store_from_db_prepare();
73  void update_store_from_db(Glib::RefPtr<Gtk::ListStore> store);
74  void handle_add_with_deps();
75 };
76 } // 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:166
horizon::PoolGitBox
Definition: pool_git_box.hpp:15