Horizon
Loading...
Searching...
No Matches
status_dispatcher.hpp
1#pragma once
2#include <glibmm/dispatcher.h>
3#include <mutex>
4#include <string>
5#include <gtkmm.h>
6
7namespace horizon {
8class StatusDispatcher : public sigc::trackable {
9public:
11
12 enum class Status { BUSY, DONE, ERROR };
13
14 void reset(const std::string &msg);
15 void set_status(Status status, const std::string &msg, double progress = -1);
16
18 public:
19 Status status;
20 std::string msg;
21 double progress;
22 };
23
24 typedef sigc::signal<void, const Notification &> type_signal_notified;
25 type_signal_notified signal_notified()
26 {
27 return s_signal_notified;
28 }
29
30 void attach(Gtk::Spinner *w);
31 void attach(Gtk::Label *w);
32 void attach(Gtk::Revealer *w);
33 void attach(Gtk::ProgressBar *w);
34 void attach(Gtk::Window *win);
35
36private:
37 void notify();
38 bool hide_revealer();
39 Glib::Dispatcher dispatcher;
40 std::mutex mutex;
41 std::string msg;
42 double progress = 0;
43 Status status = Status::DONE;
44
45 type_signal_notified s_signal_notified;
46 sigc::connection timeout_conn;
47
48 Gtk::Spinner *spinner = nullptr;
49 Gtk::Label *label = nullptr;
50 Gtk::Revealer *revealer = nullptr;
51 Gtk::ProgressBar *progress_bar = nullptr;
52 Gtk::Window *window = nullptr;
53};
54} // namespace horizon
Definition status_dispatcher.hpp:17
Definition status_dispatcher.hpp:8