Horizon
prj-mgr-app_win.hpp
1 #pragma once
2 #include "project/project.hpp"
3 #include "util/editor_process.hpp"
4 #include "util/window_state_store.hpp"
5 #include <gtkmm.h>
6 #include <memory>
7 #include <zmq.hpp>
8 
9 namespace horizon {
10 
11 class ProjectManagerViewCreate : public sigc::trackable {
12 public:
13  ProjectManagerViewCreate(const Glib::RefPtr<Gtk::Builder> &refBuilder, class ProjectManagerAppWindow *w);
14  void clear();
15  std::pair<bool, std::string> create();
16  typedef sigc::signal<void, bool> type_signal_valid_change;
17  type_signal_valid_change signal_valid_change()
18  {
19  return s_signal_valid_change;
20  }
21  void populate_pool_combo(const Glib::RefPtr<Gtk::Application> &app);
22 
23 private:
24  ProjectManagerAppWindow *win = nullptr;
25  Gtk::Entry *project_name_entry = nullptr;
26  Gtk::Entry *project_description_entry = nullptr;
27  Gtk::FileChooserButton *project_path_chooser = nullptr;
28  Gtk::Label *project_dir_label = nullptr;
29  Gtk::ComboBoxText *project_pool_combo = nullptr;
30  void update();
31 
32  type_signal_valid_change s_signal_valid_change;
33 };
34 
35 class ProjectManagerViewProject : public sigc::trackable {
36 public:
37  ProjectManagerViewProject(const Glib::RefPtr<Gtk::Builder> &refBuilder, class ProjectManagerAppWindow *w);
38  Gtk::Entry *entry_project_title = nullptr;
39  Gtk::Label *label_pool_name = nullptr;
40  Gtk::InfoBar *info_bar = nullptr;
41  Gtk::Label *info_bar_label = nullptr;
42 
43 private:
44  ProjectManagerAppWindow *win = nullptr;
45  Gtk::Button *button_top_schematic = nullptr;
46  Gtk::Button *button_board = nullptr;
47  Gtk::Button *button_part_browser = nullptr;
48  Gtk::Button *button_pool_cache = nullptr;
49 
50  void handle_button_top_schematic();
51  void handle_button_board();
52  void handle_button_part_browser();
53  void handle_button_pool_cache();
54 };
55 
57 public:
58  enum class Type { IMP_SCHEMATIC, IMP_BOARD, IMP_PADSTACK };
59  ProjectManagerProcess(Type ty, const std::vector<std::string> &args, const std::vector<std::string> &env);
60  Type type;
61  std::unique_ptr<EditorProcess> proc = nullptr;
62 };
63 
64 class ProjectManagerAppWindow : public Gtk::ApplicationWindow {
65  friend class ProjectManagerViewProject;
66  friend class ProjectManagerViewCreate;
67 
68 public:
69  ProjectManagerAppWindow(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &refBuilder,
70  class ProjectManagerApplication *app);
72 
73  static ProjectManagerAppWindow *create(class ProjectManagerApplication *app);
74 
75  void open_file_view(const Glib::RefPtr<Gio::File> &file);
76  void spawn_imp(ProjectManagerProcess::Type type, const UUID &pool_uuid, const std::vector<std::string> &args);
77  bool close_project();
78 
79 protected:
80  Glib::RefPtr<Gtk::Builder> builder;
81  Gtk::Stack *stack = nullptr;
82  Gtk::Button *button_open = nullptr;
83  Gtk::Button *button_new = nullptr;
84  Gtk::Button *button_close = nullptr;
85  Gtk::Button *button_cancel = nullptr;
86  Gtk::Button *button_create = nullptr;
87  Gtk::Button *button_save = nullptr;
88  Gtk::HeaderBar *header = nullptr;
89  Gtk::ListBox *recent_listbox = nullptr;
90  Gtk::Label *label_gitversion = nullptr;
91 
92  std::unique_ptr<Project> project = nullptr;
93  std::string project_filename;
94  std::map<std::string, ProjectManagerProcess> processes;
95  class PartBrowserWindow *part_browser_window = nullptr;
96  class PoolCacheWindow *pool_cache_window = nullptr;
97 
98  enum class ViewMode { OPEN, PROJECT, CREATE };
99  void set_view_mode(ViewMode mode);
100 
101  void handle_open();
102  void handle_new();
103  void handle_cancel();
104  void handle_create();
105  void handle_close();
106  void handle_save();
107  void handle_place_part(const UUID &uu);
108  json handle_req(const json &j);
109  ProjectManagerViewCreate view_create;
110  ProjectManagerViewProject view_project;
111 
112  bool on_delete_event(GdkEventAny *ev) override;
113  bool check_pools();
114  void update_recent_items();
115 
116  zmq::socket_t sock_project;
117  std::string sock_project_ep;
118 
119  sigc::connection sock_project_conn;
120 
121  WindowStateStore state_store;
122 };
123 }; // namespace horizon
Definition: prj-mgr-app_win.hpp:64
Definition: part_browser_window.hpp:13
a class to store JSON values
Definition: json.hpp:161
Definition: window_state_store.hpp:20
Definition: pool_cache_window.hpp:14
Definition: prj-mgr-app_win.hpp:56
Definition: prj-mgr-app.hpp:21
This class encapsulates a UUID and allows it to be uses as a value type.
Definition: uuid.hpp:16
Definition: block.cpp:7
Definition: prj-mgr-app_win.hpp:35
Definition: prj-mgr-app_win.hpp:11