33 void open_file_view(
const Glib::RefPtr<Gio::File> &file);
35 bool close_pool_or_project();
36 bool really_close_pool_or_project();
37 void wait_for_all_processes();
38 std::string get_filename()
const;
40 enum class SpawnFlags { NONE = 0, READ_ONLY = (1 << 0), TEMP = (1 << 1) };
47 SpawnResult spawn(PoolProjectManagerProcess::Type type,
const std::vector<std::string> &args,
48 SpawnFlags flags = SpawnFlags::NONE);
50 std::map<UUID, PoolProjectManagerProcess *> get_processes();
52 class Pool *pool =
nullptr;
55 typedef sigc::signal<void, std::string, int, bool> type_signal_process_exited;
56 type_signal_process_exited signal_process_exited()
58 return s_signal_process_exited;
61 typedef sigc::signal<void, std::string> type_signal_process_saved;
62 type_signal_process_saved signal_process_saved()
64 return s_signal_process_saved;
69 bool can_close =
true;
71 std::vector<UUID> procs_need_save;
76 std::string get_proc_filename(
const UUID &uu);
77 void process_save(
const UUID &uu);
78 void process_close(
const UUID &uu);
79 bool cleanup_pool_cache(Gtk::Window *parent);
81 enum class ViewMode { OPEN, POOL, PROJECT, CREATE_PROJECT, CREATE_POOL };
82 ViewMode get_view_mode()
const;
84 UUID get_pool_uuid()
const;
85 void pool_notebook_go_to(ObjectType type,
const UUID &uu);
86 void pool_notebook_show_settings_tab();
87 void open_pool(
const std::string &pool_json);
88 void update_pool_cache_status_now();
89 const std::string &get_project_title()
const;
91 void pool_update(
const std::vector<std::string> &filenames = {});
93 PoolProjectManagerApplication &app;
96 Glib::RefPtr<Gtk::Builder> builder;
97 Gtk::Stack *stack =
nullptr;
98 Gtk::Button *button_open =
nullptr;
99 Gtk::Button *button_close =
nullptr;
100 Gtk::Button *button_update =
nullptr;
101 Gtk::Button *button_cancel =
nullptr;
102 Gtk::MenuButton *button_new =
nullptr;
103 Gtk::Button *button_create =
nullptr;
104 Gtk::Button *button_save =
nullptr;
105 Gtk::MenuButton *hamburger_menu_button =
nullptr;
107 Gtk::HeaderBar *header =
nullptr;
108 Gtk::ListBox *recent_pools_listbox =
nullptr;
109 Gtk::ListBox *recent_projects_listbox =
nullptr;
110 Gtk::SearchEntry *recent_pools_search_entry =
nullptr;
111 Gtk::SearchEntry *recent_projects_search_entry =
nullptr;
112 Gtk::Stack *recent_pools_placeholder_stack =
nullptr;
113 Gtk::Stack *recent_projects_placeholder_stack =
nullptr;
114 std::vector<Gtk::ListBox *> recent_listboxes;
115 Gtk::Box *pool_box =
nullptr;
116 class PoolNotebook *pool_notebook =
nullptr;
118 Gtk::Label *pool_update_status_label =
nullptr;
119 Gtk::Revealer *pool_update_status_rev =
nullptr;
120 Gtk::Button *pool_update_status_close_button =
nullptr;
121 Gtk::ProgressBar *pool_update_progress =
nullptr;
122 sigc::connection pool_update_conn;
124 Gtk::InfoBar *info_bar =
nullptr;
125 Gtk::Label *info_bar_label =
nullptr;
126 Gtk::Button *show_output_button =
nullptr;
128 Gtk::InfoBar *info_bar_pool_not_added =
nullptr;
130 Gtk::MenuItem *menu_new_pool =
nullptr;
131 Gtk::MenuItem *menu_new_project =
nullptr;
133 class OutputWindow *output_window =
nullptr;
135 Gtk::InfoBar *info_bar_pool_doc =
nullptr;
137 Gtk::InfoBar *info_bar_version =
nullptr;
138 Gtk::Label *version_label =
nullptr;
140 Gtk::InfoBar *info_bar_gitignore =
nullptr;
142 Gtk::InfoBar *info_bar_installation_uuid_mismatch =
nullptr;
144 std::unique_ptr<class Project> project;
145 std::string project_filename;
146 bool project_needs_save =
false;
148 class PartBrowserWindow *part_browser_window =
nullptr;
150#if GTK_CHECK_VERSION(3, 24, 0)
151 static gboolean part_browser_key_pressed(GtkEventControllerKey *controller, guint keyval, guint keycode,
152 GdkModifierType state, gpointer user_data);
155 ViewMode view_mode = ViewMode::OPEN;
156 void set_view_mode(ViewMode mode);
158 void update_recent_items();
162 void handle_recent();
163 void handle_update();
164 void handle_new_project();
165 void handle_new_pool();
166 void handle_create();
167 void handle_cancel();
171 bool on_delete_event(GdkEventAny *ev)
override;
173 WindowStateStore state_store;
175 std::map<UUID, PoolProjectManagerProcess> processes;
176 std::map<int, bool> pids_need_save;
177 PoolProjectManagerProcess *find_process(
const std::string &filename);
178 PoolProjectManagerProcess *find_top_schematic_process();
179 PoolProjectManagerProcess *find_board_process();
181 const UUID uuid_pool_manager =
"1b9eecbe-7408-4b99-9aec-170d3658004a";
182 const UUID uuid_project_manager =
"144a4ad6-4c7c-4136-9920-f58f954c678e";
184 type_signal_process_exited s_signal_process_exited;
185 type_signal_process_saved s_signal_process_saved;
187 PoolProjectManagerViewCreateProject view_create_project;
188 PoolProjectManagerViewProject view_project;
189 PoolProjectManagerViewCreatePool view_create_pool;
191 void handle_place_part(
const UUID &uu);
192 void handle_assign_part(
const UUID &uu);
194 zmq::socket_t sock_mgr;
195 std::string sock_mgr_ep;
198 bool check_schema_update(
const std::string &base_path);
200 void check_pool_update(
const std::string &base_path);
201 void check_mtimes(
const std::string &base_path);
202 std::thread check_mtimes_thread;
203 Glib::Dispatcher check_mtimes_dispatcher;
205 bool check_autosave(PoolProjectManagerProcess::Type type,
const std::vector<std::string> &filenames);
207 void set_version_info(
const std::string &s);
208 bool project_read_only =
false;
210 bool migrate_project(
const std::string &path);
211 std::string project_title;
213 Glib::Dispatcher pool_update_dispatcher;
214 bool in_pool_update_handler =
false;
215 std::mutex pool_update_status_queue_mutex;
216 std::list<std::tuple<PoolUpdateStatus, std::string, std::string>> pool_update_status_queue;
217 std::list<std::tuple<PoolUpdateStatus, std::string, std::string>> pool_update_error_queue;
218 bool pool_updating =
false;
219 void pool_updated(
bool success);
220 std::string pool_update_last_file;
221 std::string pool_update_last_info;
222 unsigned int pool_update_n_files = 0;
223 unsigned int pool_update_n_files_last = 0;
224 std::vector<std::string> pool_update_filenames;
226 void pool_update_thread();
227 void handle_pool_update_progress();
228 void set_pool_updating(
bool v,
bool success);
229 void set_pool_update_status_text(
const std::string &txt);
230 void set_pool_update_progress(
float progress);
232 std::string get_pool_base_path()
const;
234 std::string get_gitignore_filename()
const;
236 void update_recent_search(Gtk::SearchEntry &entry, Gtk::ListBox &lb);
237 void update_recent_searches();
238 void clear_recent_searches();
240 void update_recent_placeholder(Gtk::Stack &stack, Gtk::ListBox &lb);
243 zmq::context_t &zctx;