Horizon
pool-mgr-app_win.hpp
1 #pragma once
2 #include <gtkmm.h>
3 #include <memory>
4 #include "util/uuid.hpp"
5 #include <zmq.hpp>
6 #include "nlohmann/json_fwd.hpp"
7 #include "util/editor_process.hpp"
8 #include "util/window_state_store.hpp"
9 
10 namespace horizon {
11 using json = nlohmann::json;
12 
13 class PoolManagerAppWindow : public Gtk::ApplicationWindow {
14  friend class ProjectManagerViewProject;
15 
16 public:
17  PoolManagerAppWindow(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &refBuilder,
18  class PoolManagerApplication *app);
20 
21  static PoolManagerAppWindow *create(class PoolManagerApplication *app);
22 
23  void open_file_view(const Glib::RefPtr<Gio::File> &file);
24  bool close_pool();
25 
26 protected:
27  Glib::RefPtr<Gtk::Builder> builder;
28  Gtk::Stack *stack = nullptr;
29  Gtk::Button *button_open = nullptr;
30  Gtk::Button *button_close = nullptr;
31  Gtk::Button *button_update = nullptr;
32  Gtk::Button *button_download = nullptr;
33  Gtk::Button *button_do_download = nullptr;
34  Gtk::Button *button_cancel = nullptr;
35  Gtk::Spinner *spinner_update = nullptr;
36  Gtk::Revealer *download_revealer = nullptr;
37  Gtk::Label *download_label = nullptr;
38 
39  Gtk::Entry *download_gh_username_entry = nullptr;
40  Gtk::Entry *download_gh_repo_entry = nullptr;
41  Gtk::FileChooserButton *download_dest_dir_button = nullptr;
42 
43  Gtk::HeaderBar *header = nullptr;
44  Gtk::ListBox *recent_listbox = nullptr;
45  Gtk::Label *label_gitversion = nullptr;
46  Gtk::Box *pool_box = nullptr;
47  class PoolNotebook *pool_notebook = nullptr;
48 
49  Gtk::Label *pool_update_status_label = nullptr;
50  Gtk::Revealer *pool_update_status_rev = nullptr;
51  Gtk::Button *pool_update_status_close_button = nullptr;
52  Gtk::ProgressBar *pool_update_progress = nullptr;
53 
54  std::string pool_base_path;
55 
56  enum class ViewMode { OPEN, POOL, DOWNLOAD };
57  void set_view_mode(ViewMode mode);
58 
59  void update_recent_items();
60 
61  void handle_open();
62  void handle_close();
63  void handle_recent();
64  void handle_update();
65  void handle_download();
66  void handle_do_download();
67  void handle_cancel();
68  json handle_req(const json &j);
69 
70  bool on_delete_event(GdkEventAny *ev) override;
71 
72  void download_thread(std::string gh_username, std::string gh_repo, std::string dest_dir);
73 
74  Glib::Dispatcher download_dispatcher;
75 
76  bool downloading = false;
77  bool download_error = false;
78  std::string download_status;
79  std::mutex download_mutex;
80 
81 
82  WindowStateStore state_store;
83 
84 public:
85  zmq::context_t &zctx;
86  void set_pool_updating(bool v, bool success);
87  void set_pool_update_status_text(const std::string &txt);
88  void set_pool_update_progress(float progress);
89 };
90 }; // namespace horizon
a class to store JSON values
Definition: json.hpp:161
Definition: pool_notebook.hpp:38
Definition: window_state_store.hpp:20
Definition: pool-mgr-app_win.hpp:13
Definition: pool-mgr-app.hpp:12
Definition: block.cpp:7
Definition: prj-mgr-app_win.hpp:35
basic_json<> json
default JSON class
Definition: json_fwd.hpp:61