summaryrefslogtreecommitdiff
path: root/src/monitor-gui.cc
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@yahoo.com>2017-07-23 03:45:40 +0200
committerJoel Klinghed <the_jk@yahoo.com>2017-07-23 03:45:40 +0200
commitff8e353290c0b443c0ec68ee3fc4e137a7025f27 (patch)
treec19b6c228fe57be695863bef54e9d4f3b4893e95 /src/monitor-gui.cc
parenta66d21a1fd7b53997c27279f6269e9226f06fb6b (diff)
Add proxy log window
Both GTK and QT log windows will scroll down to the last row whenever a new row is appended.
Diffstat (limited to 'src/monitor-gui.cc')
-rw-r--r--src/monitor-gui.cc26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/monitor-gui.cc b/src/monitor-gui.cc
index c88bb8e..fa43169 100644
--- a/src/monitor-gui.cc
+++ b/src/monitor-gui.cc
@@ -19,6 +19,7 @@
#include "gui_menu.hh"
#include "gui_main.hh"
#include "gui_statusbar.hh"
+#include "gui_textwnd.hh"
#include "io.hh"
#include "logger.hh"
#include "looper.hh"
@@ -37,6 +38,7 @@ std::string const ACTION_ABOUT = "about";
std::string const ACTION_COPY_RAW = "copy_raw";
std::string const ACTION_COPY_TEXT = "copy_text";
std::string const ACTION_CLEAR = "clear";
+std::string const ACTION_PROXY_LOG = "proxy_log";
bool valid_hostname(std::string const& host) {
return !host.empty();
@@ -315,7 +317,8 @@ private:
std::unique_ptr<AttributedText> text_;
};
-class MonitorGui : GuiMenu::Listener, GuiMain::Listener, Monitor::Delegate {
+class MonitorGui : GuiMenu::Listener, GuiMain::Listener, Monitor::Delegate,
+ GuiTextWindow::Listener {
private:
class ConnectFormListener : public GuiFormApply::Listener {
public:
@@ -436,7 +439,7 @@ private:
public:
MonitorGui()
: packages_(new PackageList()),
- main_(GuiMain::create("TransparentProxy Monitor", 800, 400)),
+ main_(GuiMain::create("TransparentProxy Monitor", 800, 500)),
menu_(GuiMenu::create()),
statusbar_(GuiStatusBar::create()),
looper_(main_->createLooper()),
@@ -455,6 +458,7 @@ public:
edit->add_item(ACTION_CLEAR, "Clear");
auto help = menu_->add_menu("Help");
help->add_item(ACTION_ABOUT, "About...");
+ help->add_item(ACTION_PROXY_LOG, "Proxy log...");
main_->set_menu(menu_.get());
main_->set_statusbar(statusbar_.get());
main_->set_split(0.7);
@@ -565,6 +569,16 @@ public:
main_->add_to_clipboard(pkg.data, "application/octet-stream");
} else if (id == ACTION_CLEAR) {
packages_->clear();
+ } else if (id == ACTION_PROXY_LOG) {
+ if (!proxy_logwnd_) {
+ if (!proxy_logger_) proxy_logger_.reset(new StringLogger());
+ proxy_logwnd_.reset(GuiTextWindow::create(
+ "Proxy log", 500, 200, proxy_logger_->text()));
+ proxy_logwnd_->add_listener(this);
+ proxy_logwnd_->show(main_.get());
+ } else {
+ proxy_logwnd_->focus();
+ }
} else {
assert(false);
}
@@ -600,6 +614,13 @@ public:
menu_->enable_item(ACTION_COPY_TEXT, false);
}
+ // GuiTextWindow::Listener
+ bool about_to_close(GuiTextWindow* wnd) override {
+ assert(proxy_logwnd_.get() == wnd);
+ proxy_logwnd_.reset();
+ return true;
+ }
+
// Monitor::Delegate
void state(Monitor* monitor, Monitor::State state) override {
assert(monitor == monitor_.get());
@@ -695,6 +716,7 @@ private:
std::unique_ptr<Config> proxy_config_;
std::unique_ptr<StringLogger> proxy_logger_;
std::unique_ptr<Proxy> proxy_;
+ std::unique_ptr<GuiTextWindow> proxy_logwnd_;
bool has_selection_;
size_t selection_;
};