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:
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:
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
51 class PreferencesWindow *show_preferences_window(guint32 timestamp = 0);
52 class PoolsWindow *show_pools_window(guint32 timestamp = 0);
53 class LogWindow *show_log_window(guint32 timestamp = 0);
54
55 typedef sigc::signal<void, std::vector<std::string>> type_signal_pool_items_edited;
56 type_signal_pool_items_edited signal_pool_items_edited()
57 {
58 return s_signal_pool_items_edited;
59 }
60
61 typedef sigc::signal<void, std::string> type_signal_pool_updated;
62 type_signal_pool_updated signal_pool_updated()
63 {
64 return s_signal_pool_updated;
65 }
66
67 typedef sigc::signal<void> type_signal_recent_items_changed;
68 type_signal_recent_items_changed signal_recent_items_changed()
69 {
70 return s_signal_recent_items_changed;
71 }
72
75 bool close = true;
76 };
77 bool close_windows(std::vector<CloseOrHomeWindow> windows);
78
79 bool present_existing_window(const std::string &path);
80
81protected:
82 // Override default signal handlers:
83 void on_activate() override;
84 void on_startup() override;
85 void on_shutdown();
86 void on_open(const Gio::Application::type_vec_files &files, const Glib::ustring &hint) override;
87
88 std::string sock_broadcast_ep;
89
90
91private:
92 class PoolProjectManagerAppWindow *create_appwindow();
93 void on_hide_window(Gtk::Window *window);
94 void on_action_quit();
95 void on_action_new_window();
96 void on_action_about();
97 Preferences preferences;
98 class PreferencesWindow *preferences_window = nullptr;
99 class PoolsWindow *pools_window = nullptr;
100
101 LogDispatcher log_dispatcher;
102 class LogWindow *log_window = nullptr;
103
104 type_signal_pool_items_edited s_signal_pool_items_edited;
105 type_signal_pool_updated s_signal_pool_updated;
106 type_signal_recent_items_changed s_signal_recent_items_changed;
107
108 std::string get_config_filename();
109
110public:
111 const UUID ipc_cookie;
112 zmq::socket_t sock_broadcast;
113};
114} // 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 pool-prj-mgr-app.hpp:16
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
a class to store JSON values
Definition json.hpp:177
basic_json<> json
default JSON class
Definition json_fwd.hpp:62