Horizon
pool_notebook.hpp
1 #pragma once
2 #include <gtkmm.h>
3 #include <memory>
4 #include "util/uuid.hpp"
5 #include "pool/part.hpp"
6 #include "pool/unit.hpp"
7 #include "pool/entity.hpp"
8 #include "pool/symbol.hpp"
9 #include "pool/package.hpp"
10 #include "pool/padstack.hpp"
11 
12 #include "pool/pool.hpp"
13 #include "util/editor_process.hpp"
14 #include "pool-update/pool-update.hpp"
15 #include <zmq.hpp>
16 
17 namespace horizon {
18 
19 class PoolManagerProcess : public sigc::trackable {
20 public:
21  enum class Type { IMP_SYMBOL, IMP_PADSTACK, IMP_PACKAGE, UNIT, ENTITY, PART };
22  PoolManagerProcess(Type ty, const std::vector<std::string> &args, const std::vector<std::string> &env,
23  class Pool *pool);
24  Type type;
25  std::unique_ptr<EditorProcess> proc = nullptr;
26  class EditorWindow *win = nullptr;
27  typedef sigc::signal<void, int, bool> type_signal_exited;
28  type_signal_exited signal_exited()
29  {
30  return s_signal_exited;
31  }
32  void reload();
33 
34 private:
35  type_signal_exited s_signal_exited;
36 };
37 
38 class PoolNotebook : public Gtk::Notebook {
39  friend class PoolRemoteBox;
40 
41 public:
42  PoolNotebook(const std::string &bp, class PoolManagerAppWindow *aw);
43  void populate();
44  void spawn(PoolManagerProcess::Type type, const std::vector<std::string> &args);
45  bool can_close();
46  void prepare_close();
47  void pool_update(std::function<void()> cb = nullptr);
48  ~PoolNotebook();
49 
50 private:
51  const std::string base_path;
52  Pool pool;
53  class PoolManagerAppWindow *appwin;
54  std::map<std::string, PoolManagerProcess> processes;
55  std::map<ObjectType, class PoolBrowser *> browsers;
56  class PartWizard *part_wizard = nullptr;
57  class DuplicateWindow *duplicate_window = nullptr;
58 
59  Glib::Dispatcher pool_update_dispatcher;
60  std::mutex pool_update_status_queue_mutex;
61  std::deque<std::tuple<PoolUpdateStatus, std::string, std::string>> pool_update_status_queue;
62  std::deque<std::tuple<PoolUpdateStatus, std::string, std::string>> pool_update_error_queue;
63  bool pool_updating = false;
64  void pool_updated(bool success);
65  std::string pool_update_last_file;
66  unsigned int pool_update_n_files = 0;
67  unsigned int pool_update_n_files_last = 0;
68  std::function<void()> pool_update_done_cb = nullptr;
69 
70  void pool_update_thread();
71 
72  void show_duplicate_window(ObjectType ty, const UUID &uu);
73 
74  void handle_create_unit();
75  void handle_edit_unit(const UUID &uu);
76  void handle_create_symbol_for_unit(const UUID &uu);
77  void handle_create_entity_for_unit(const UUID &uu);
78  void handle_duplicate_unit(const UUID &uu);
79 
80  void handle_edit_symbol(const UUID &uu);
81  void handle_create_symbol();
82  void handle_duplicate_symbol(const UUID &uu);
83 
84  void handle_edit_entity(const UUID &uu);
85  void handle_create_entity();
86  void handle_duplicate_entity(const UUID &uu);
87 
88  void handle_edit_padstack(const UUID &uu);
89  void handle_create_padstack();
90  void handle_duplicate_padstack(const UUID &uu);
91 
92  void handle_edit_package(const UUID &uu);
93  void handle_create_package();
94  void handle_create_padstack_for_package(const UUID &uu);
95  void handle_duplicate_package(const UUID &uu);
96  void handle_part_wizard(const UUID &uu);
97 
98  void handle_edit_part(const UUID &uu);
99  void handle_create_part();
100  void handle_create_part_from_part(const UUID &uu);
101  void handle_duplicate_part(const UUID &uu);
102 
103  Gtk::Button *add_action_button(const std::string &label, Gtk::Box *bbox, sigc::slot0<void>);
104  Gtk::Button *add_action_button(const std::string &label, Gtk::Box *bbox, class PoolBrowser *br,
105  sigc::slot1<void, UUID>);
106 
107  void handle_delete(ObjectType ty, const UUID &uu);
108  void handle_copy_path(ObjectType ty, const UUID &uu);
109  void add_context_menu(class PoolBrowser *br);
110 
111  std::string remote_repo;
112  class PoolRemoteBox *remote_box = nullptr;
113 
114  void go_to(ObjectType type, const UUID &uu);
115 };
116 } // namespace horizon
Definition: pool_notebook.hpp:38
Definition: duplicate_window.hpp:7
Definition: pool_remote_box.hpp:14
Definition: pool-mgr-app_win.hpp:13
Definition: part_wizard.hpp:12
Definition: pool_notebook.hpp:19
This class encapsulates a UUID and allows it to be uses as a value type.
Definition: uuid.hpp:16
Definition: pool_browser.hpp:11
Stores objects (Unit, Entity, Symbol, Part, etc.) from the pool.
Definition: pool.hpp:18
Definition: block.cpp:7
Definition: editor_window.hpp:20