-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgui.cpp
More file actions
36 lines (30 loc) · 941 Bytes
/
gui.cpp
File metadata and controls
36 lines (30 loc) · 941 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "gui.h"
#include <iostream>
CHMERGui::CHMERGui() {
setup_widgets();
}
CHMERGui::~CHMERGui() {}
void CHMERGui::setup_widgets() {
scrolled.add(textview);
scrolled.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
window.add(scrolled);
window.set_default_size(600, 400);
window.set_title("CHMER GUI");
window.show_all_children();
}
void CHMERGui::launch_gui(int argc, char** argv) {
auto app = Gtk::Application::create(argc, argv, "chmer.gui");
app->run(window);
}
void CHMERGui::append_text(const std::string& text) {
std::lock_guard<std::mutex> lock(mtx);
auto buffer = textview.get_buffer();
buffer->insert(buffer->end(), text + "\n");
auto iter = buffer->end(); // store iterator in a variable
textview.scroll_to(iter);
}
void CHMERGui::clear_text() {
std::lock_guard<std::mutex> lock(mtx);
auto buffer = textview.get_buffer();
buffer->set_text("");
}