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 "pool/pool_parametric.hpp"
14 #include "util/editor_process.hpp"
15 #include "pool-update/pool-update.hpp"
16 #include <zmq.hpp>
17 #ifdef G_OS_WIN32
18 #undef ERROR
19 #undef DELETE
20 #undef DUPLICATE
21 #endif
22 
23 namespace horizon {
24 class PoolNotebook : public Gtk::Notebook {
25  friend class PoolRemoteBox;
26  friend class PoolGitBox;
27 
28 public:
29  PoolNotebook(const std::string &bp, class PoolProjectManagerAppWindow *aw);
30  void populate();
31  bool get_close_prohibited() const;
32  void prepare_close();
33  void pool_update(std::function<void()> cb = nullptr, const std::vector<std::string> &filenames = {});
34  bool get_needs_save() const;
35  void save();
36  void go_to(ObjectType type, const UUID &uu);
37  const UUID &get_pool_uuid() const;
38  ~PoolNotebook();
39 
40 private:
41  const std::string base_path;
42  Pool pool;
43  PoolParametric pool_parametric;
44  class PoolProjectManagerAppWindow *appwin;
45  std::map<ObjectType, class PoolBrowser *> browsers;
46  std::map<std::string, class PoolBrowserParametric *> browsers_parametric;
47  class PartWizard *part_wizard = nullptr;
48  class DuplicateWindow *duplicate_window = nullptr;
49  bool closing = false;
50 
51  Glib::Dispatcher pool_update_dispatcher;
52  bool in_pool_update_handler = false;
53  std::mutex pool_update_status_queue_mutex;
54  std::deque<std::tuple<PoolUpdateStatus, std::string, std::string>> pool_update_status_queue;
55  std::deque<std::tuple<PoolUpdateStatus, std::string, std::string>> pool_update_error_queue;
56  bool pool_updating = false;
57  void pool_updated(bool success);
58  std::string pool_update_last_file;
59  unsigned int pool_update_n_files = 0;
60  unsigned int pool_update_n_files_last = 0;
61  std::function<void()> pool_update_done_cb = nullptr;
62  std::vector<std::string> pool_update_filenames;
63 
64  void pool_update_thread();
65 
66  void show_duplicate_window(ObjectType ty, const UUID &uu);
67 
68  void construct_units();
69  void handle_create_unit();
70  void handle_edit_unit(const UUID &uu);
71  void handle_create_symbol_for_unit(const UUID &uu);
72  void handle_create_entity_for_unit(const UUID &uu);
73  void handle_duplicate_unit(const UUID &uu);
74 
75  void construct_symbols();
76  void handle_edit_symbol(const UUID &uu);
77  void handle_create_symbol();
78  void handle_duplicate_symbol(const UUID &uu);
79 
80  void construct_entities();
81  void handle_edit_entity(const UUID &uu);
82  void handle_create_entity();
83  void handle_duplicate_entity(const UUID &uu);
84 
85  void construct_padstacks();
86  void handle_edit_padstack(const UUID &uu);
87  void handle_create_padstack();
88  void handle_duplicate_padstack(const UUID &uu);
89 
90  void construct_packages();
91  void handle_edit_package(const UUID &uu);
92  void handle_create_package();
93  void handle_create_padstack_for_package(const UUID &uu);
94  void handle_duplicate_package(const UUID &uu);
95  void handle_part_wizard(const UUID &uu);
96 
97  void construct_parts();
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  void construct_frames();
104  void handle_edit_frame(const UUID &uu);
105  void handle_create_frame();
106  void handle_duplicate_frame(const UUID &uu);
107 
108  Gtk::Button *add_action_button(const std::string &label, Gtk::Box *bbox, sigc::slot0<void>);
109  Gtk::Button *add_action_button(const std::string &label, Gtk::Box *bbox, class PoolBrowser *br,
110  sigc::slot1<void, UUID>);
111  void add_preview_stack_switcher(Gtk::Box *bbox, Gtk::Stack *stack);
112 
113  void handle_delete(ObjectType ty, const UUID &uu);
114  void handle_copy_path(ObjectType ty, const UUID &uu);
115  void add_context_menu(class PoolBrowser *br);
116 
117  void install_search_once(Gtk::Widget *page, PoolBrowser *browser);
118  bool widget_is_visible(Gtk::Widget *widget);
119 
120  std::string remote_repo;
121  class PoolRemoteBox *remote_box = nullptr;
122  class PoolSettingsBox *settings_box = nullptr;
123  class PoolGitBox *git_box = nullptr;
124 
125  UUID pool_uuid;
126 };
127 } // namespace horizon
horizon::PoolRemoteBox
Definition: pool_remote_box.hpp:14
horizon::PoolBrowser
Definition: pool_browser.hpp:11
horizon::PoolNotebook
Definition: pool_notebook.hpp:24
horizon::PoolSettingsBox
Definition: pool_settings_box.hpp:13
horizon::DuplicateWindow
Definition: duplicate_window.hpp:7
horizon::PartWizard
Definition: part_wizard.hpp:16
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::PoolGitBox
Definition: pool_git_box.hpp:15
horizon::PoolParametric
Definition: pool_parametric.hpp:10
horizon::PoolProjectManagerAppWindow
Definition: pool-prj-mgr-app_win.hpp:24