Horizon
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 
13 namespace horizon {
14 using json = nlohmann::json;
15 
16 class PoolProjectManagerApplication : public Gtk::Application {
17 protected:
19 
20 public:
21  static Glib::RefPtr<PoolProjectManagerApplication> create();
22  std::string get_config_filename();
23  const std::string &get_ep_broadcast() const;
24  void send_json(int pid, const json &j);
25  zmq::context_t zctx;
26 
27  std::map<std::string, Glib::DateTime> recent_items;
28 
29  std::deque<UUID> part_favorites;
30  bool pool_doc_info_bar_dismissed = false;
31 
32  void close_appwindows(std::set<Gtk::Window *> wins);
33  Preferences &get_preferences();
34 
35  void open_pool(const std::string &pool_json, ObjectType type = ObjectType::INVALID, const UUID &uu = UUID(),
36  guint32 timestamp = 0);
37 
38  class PreferencesWindow *show_preferences_window(guint32 timestamp = 0);
39  class LogWindow *show_log_window(guint32 timestamp = 0);
40 
41  typedef sigc::signal<void, UUID> type_signal_pool_updated;
42  type_signal_pool_updated signal_pool_updated()
43  {
44  return s_signal_pool_updated;
45  }
46 
47 protected:
48  // Override default signal handlers:
49  void on_activate() override;
50  void on_startup() override;
51  void on_shutdown();
52  void on_open(const Gio::Application::type_vec_files &files, const Glib::ustring &hint) override;
53 
54  std::string sock_broadcast_ep;
55 
56 
57 private:
58  class PoolProjectManagerAppWindow *create_appwindow();
59  void on_hide_window(Gtk::Window *window);
60  void on_action_quit();
61  void on_action_new_window();
62  void on_action_about();
63  void load_from_config(const std::string &config_filename);
64  Preferences preferences;
65  class PreferencesWindow *preferences_window = nullptr;
66 
67  LogDispatcher log_dispatcher;
68  class LogWindow *log_window = nullptr;
69 
70  type_signal_pool_updated s_signal_pool_updated;
71 
72 
73 public:
74  zmq::socket_t sock_broadcast;
75 };
76 } // namespace horizon
horizon::LogWindow
Definition: log_window.hpp:6
horizon::Preferences
Definition: preferences.hpp:99
horizon::LogDispatcher
Definition: log_dispatcher.hpp:8
nlohmann::basic_json
a class to store JSON values
Definition: json.hpp:166
horizon::UUID
This class encapsulates a UUID and allows it to be uses as a value type.
Definition: uuid.hpp:16
nlohmann::json
basic_json<> json
default JSON class
Definition: json_fwd.hpp:61
horizon::PreferencesWindow
Definition: preferences_window.hpp:7
horizon::PoolProjectManagerApplication
Definition: pool-prj-mgr-app.hpp:16
horizon::PoolProjectManagerAppWindow
Definition: pool-prj-mgr-app_win.hpp:21