Horizon
Loading...
Searching...
No Matches
pool-prj-mgr-app.hpp
1#pragma once
2#include <gtkmm.h>
3#include "util/uuid.hpp"
4#include "nlohmann/json_fwd.hpp"
5#include <map>
6#include <set>
7#include <zmq.hpp>
8#include <glibmm/datetime.h>
9#include "util/win32_undef.hpp"
10#include "preferences/preferences.hpp"
11#include "logger/log_dispatcher.hpp"
12
13namespace horizon {
14using json = nlohmann::json;
15
16class PoolProjectManagerApplication : public Gtk::Application {
17protected:
18 PoolProjectManagerApplication();
19
20public:
21 static Glib::RefPtr<PoolProjectManagerApplication> create();
22 const std::string &get_ep_broadcast() const;
23 void send_json(int pid, const json &j);
24 zmq::context_t zctx;
25
26
27 void add_recent_item(const std::string &path);
28 class UserConfig {
29 private:
30 friend PoolProjectManagerApplication;
31 UserConfig() = default;
32 void load(const std::string &filename);
33 void save(const std::string &filename);
34
35 public:
36 std::map<std::string, Glib::DateTime> recent_items;
37 std::deque<UUID> part_favorites;
38 bool pool_doc_info_bar_dismissed = false;
39 std::string project_author;
40 std::string project_base_path;
41 UUID project_pool;
42 };
43
44 UserConfig user_config;
45
46 void close_appwindows(std::set<Gtk::Window *> wins);
47 Preferences &get_preferences();
48
49 class PoolProjectManagerAppWindow &open_pool_or_project(const std::string &pool_json, guint32 timestamp = 0,
50 const std::string &token = "");
51
52 class PreferencesWindow *show_preferences_window(guint32 timestamp = 0, const std::string &token = "");
53 class PoolsWindow *show_pools_window(guint32 timestamp = 0, const std::string &token = "");
54 class LogWindow *show_log_window(guint32 timestamp = 0, const std::string &token = "");
55
56 typedef sigc::signal<void, std::vector<std::string>> type_signal_pool_items_edited;
57 type_signal_pool_items_edited signal_pool_items_edited()
58 {
59 return s_signal_pool_items_edited;
60 }
61
62 typedef sigc::signal<void, std::string> type_signal_pool_updated;
63 type_signal_pool_updated signal_pool_updated()
64 {
65 return s_signal_pool_updated;
66 }
67
68 typedef sigc::signal<void> type_signal_recent_items_changed;
69 type_signal_recent_items_changed signal_recent_items_changed()
70 {
71 return s_signal_recent_items_changed;
72 }
73
76 bool close = true;
77 };
78 bool close_windows(std::vector<CloseOrHomeWindow> windows);
79
80 bool present_existing_window(const std::string &path);
81
82protected:
83 // Override default signal handlers:
84 void on_activate() override;
85 void on_startup() override;
86 void on_shutdown();
87 void on_open(const Gio::Application::type_vec_files &files, const Glib::ustring &hint) override;
88
89 std::string sock_broadcast_ep;
90
91
92private:
93 class PoolProjectManagerAppWindow *create_appwindow();
94 void on_hide_window(Gtk::Window *window);
95 void on_action_quit();
96 void on_action_new_window();
97 void on_action_about();
98 Preferences preferences;
99 class PreferencesWindow *preferences_window = nullptr;
100 class PoolsWindow *pools_window = nullptr;
101
102 LogDispatcher log_dispatcher;
103 class LogWindow *log_window = nullptr;
104
105 type_signal_pool_items_edited s_signal_pool_items_edited;
106 type_signal_pool_updated s_signal_pool_updated;
107 type_signal_recent_items_changed s_signal_recent_items_changed;
108
109 std::string get_config_filename();
110
111public:
112 const UUID ipc_cookie;
113 zmq::socket_t sock_broadcast;
114};
115} // namespace horizon
Definition log_dispatcher.hpp:9
Definition log_window.hpp:6
Definition pool-prj-mgr-app_win.hpp:22
Definition pool-prj-mgr-app.hpp:28
Definition pools_window.hpp:10
Definition preferences_window.hpp:7
Definition preferences.hpp:167
This class encapsulates a UUID and allows it to be uses as a value type.
Definition uuid.hpp:16
basic_json<> json
default JSON class
Definition json_fwd.hpp:62