Horizon
pool_remote_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 #include "util/status_dispatcher.hpp"
10 #include "util/item_set.hpp"
11 
12 namespace horizon {
13 using json = nlohmann::json;
14 
15 class PoolRemoteBox : public Gtk::Box {
16 public:
17  PoolRemoteBox(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &x, class PoolNotebook *nb);
18  static PoolRemoteBox *create(class PoolNotebook *nb);
19 
20  void merge_item(ObjectType ty, const UUID &uu);
21  void merge_3d_model(const std::string &filename);
22  void handle_refresh_prs();
23  bool prs_refreshed_once = false;
24 
25 private:
26  class PoolNotebook *notebook = nullptr;
27 
28  class ListColumns : public Gtk::TreeModelColumnRecord {
29  public:
30  ListColumns()
31  {
32  Gtk::TreeModelColumnRecord::add(name);
33  Gtk::TreeModelColumnRecord::add(type);
34  Gtk::TreeModelColumnRecord::add(uuid);
35  Gtk::TreeModelColumnRecord::add(filename);
36  }
37  Gtk::TreeModelColumn<Glib::ustring> name;
38  Gtk::TreeModelColumn<ObjectType> type;
39  Gtk::TreeModelColumn<UUID> uuid;
40  Gtk::TreeModelColumn<std::string> filename;
41  };
42  ListColumns list_columns;
43 
44  Glib::RefPtr<Gtk::ListStore> item_store;
45  Gtk::TreeView *merge_items_view = nullptr;
46  Gtk::Label *merge_items_placeholder_label = nullptr;
47  Gtk::Label *pr_body_placeholder_label = nullptr;
48  Gtk::Button *upgrade_button = nullptr;
49  Gtk::Button *create_pr_button = nullptr;
50  Gtk::Button *refresh_prs_button = nullptr;
51  Gtk::Revealer *upgrade_revealer = nullptr;
52  Gtk::Label *upgrade_label = nullptr;
53  Gtk::Spinner *upgrade_spinner = nullptr;
54  Gtk::Label *gh_repo_link_label = nullptr;
55  Gtk::Label *gh_signed_in_label = nullptr;
56  Gtk::Button *merge_items_clear_button = nullptr;
57  Gtk::Button *merge_items_remove_button = nullptr;
58  Gtk::Entry *pr_title_entry = nullptr;
59  Gtk::TextView *pr_body_textview = nullptr;
60  Gtk::ListBox *pull_requests_listbox = nullptr;
61  Gtk::Spinner *pr_spinner = nullptr;
62  StatusDispatcher pr_status_dispatcher;
63 
64 
65  void handle_remote_upgrade();
66  void handle_create_pr();
67  void update_body_placeholder_label();
68 
69 
70  void remote_upgrade_thread();
71  void create_pr_thread();
72  void refresh_prs_thread();
73  void checkout_master(git_repository *repo);
74 
75  Glib::Dispatcher git_thread_dispatcher;
76 
77  enum class GitThreadMode { UPGRADE, PULL_REQUEST };
78  GitThreadMode git_thread_mode = GitThreadMode::UPGRADE;
79  bool git_thread_busy = false;
80  std::string git_thread_status;
81  bool git_thread_error = false;
82  json pull_requests;
83  std::mutex git_thread_mutex;
84 
85  std::string gh_owner;
86  std::string gh_repo;
87 
88  ItemSet items_merge;
89  std::set<std::string> models_merge;
90  void update_items_merge();
91  ItemSet get_referenced(ObjectType ty, const UUID &uu);
92  bool exists_in_pool(class Pool &pool, ObjectType ty, const UUID &uu);
93 
94  void update_prs();
95 
96  std::string gh_username;
97  std::string gh_password;
98 
99  std::string pr_title;
100  std::string pr_body;
101 };
102 } // namespace horizon
horizon::PoolRemoteBox
Definition: pool_remote_box.hpp:15
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::UUID
This class encapsulates a UUID and allows it to be uses as a value type.
Definition: uuid.hpp:16
horizon::Pool
Stores objects (Unit, Entity, Symbol, Part, etc.) from the pool.
Definition: pool.hpp:21
horizon::StatusDispatcher
Definition: status_dispatcher.hpp:8