diff --git a/src/window.cpp b/src/window.cpp index face5d6..dbd2866 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -28,7 +28,7 @@ Window::Window() : m_vbox(Gtk::ORIENTATION_VERTICAL) { tree = std::make_unique(all_readings, device_names); // Start a new worker thread: - m_Dispatcher.connect(sigc::mem_fun(*this, &Window::update_all)); + m_Dispatcher.connect(sigc::mem_fun(*this, &Window::update_all_components)); set_border_width(1); set_default_size(500, 600); @@ -87,7 +87,8 @@ Window::Window() : m_vbox(Gtk::ORIENTATION_VERTICAL) { Window::~Window() { on_button_quit(); } -void Window::update_vals() { +void Window::update_device_vals() { + // Refresh values every second while (1) { if (stop_work) { break; @@ -102,7 +103,8 @@ void Window::update_vals() { } } -void Window::update_all() { +void Window::update_all_components() { + // Update the values on the tree and graphs tree->update_tree_view(all_readings); for (auto &page : m_notebook_graphs) { for (auto &graph : page) { @@ -114,6 +116,8 @@ void Window::update_all() { } vector Window::gen_colors(unsigned int size) { + // This could probably go somewhere else, but the colors are shared between + // the graphs and legends... vector rainbow; static const vector m_colors = { "green", "red", "blue", "orange", "violet", "brown", diff --git a/src/window.h b/src/window.h index df51e68..3af005a 100644 --- a/src/window.h +++ b/src/window.h @@ -19,31 +19,33 @@ class Window : public Gtk::Window { private: const std::string file_path = "/sys/class/hwmon/"; - bool stop_work = false; + // Computer Devices: vector devices; vector>> all_readings; vector device_names; - + // Summary tree + Gtk::ScrolledWindow m_scrolledwindow; + std::unique_ptr tree; + // Notebook: + Gtk::Notebook m_notebook; vector m_Notebook_Boxes; vector>> m_notebook_graphs; vector>> m_notebook_legends; vector>> m_colors; - + // Async value updates to prevent stalls: Glib::Dispatcher m_Dispatcher; + bool stop_work = false; std::unique_ptr m_WorkerThread = - std::make_unique([this] { update_vals(); }); - - std::unique_ptr tree; + std::make_unique([this] { update_device_vals(); }); + // Other important stuffs: Gtk::Box m_vbox; Gtk::HeaderBar m_headerbar; Gtk::StackSwitcher m_stackswitcher; Gtk::Stack m_stack; - Gtk::Notebook m_notebook; - Gtk::ScrolledWindow m_scrolledwindow; - void update_vals(); - void update_all(); + void update_device_vals(); + void update_all_components(); vector gen_colors(unsigned int size); void on_button_quit(); };