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