diff options
author | David Robillard <d@drobilla.net> | 2020-11-27 18:54:27 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-11-27 21:52:17 +0100 |
commit | dbe6899651ac929f59af160dd07aaf6bda079b23 (patch) | |
tree | 49243cfa13dc3bba18526dc5eeb64f615a23c587 /src/TextViewLog.hpp | |
parent | 5dad45517e9dfa8b043f368cf31b2795fb713fde (diff) | |
download | patchage-dbe6899651ac929f59af160dd07aaf6bda079b23.tar.gz patchage-dbe6899651ac929f59af160dd07aaf6bda079b23.tar.bz2 patchage-dbe6899651ac929f59af160dd07aaf6bda079b23.zip |
Factor out log from Patchage class
Towards saner dependencies.
Diffstat (limited to 'src/TextViewLog.hpp')
-rw-r--r-- | src/TextViewLog.hpp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/TextViewLog.hpp b/src/TextViewLog.hpp new file mode 100644 index 0000000..eb44407 --- /dev/null +++ b/src/TextViewLog.hpp @@ -0,0 +1,56 @@ +/* This file is part of Patchage. + * Copyright 2007-2020 David Robillard <d@drobilla.net> + * + * Patchage is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * Patchage is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. + * + * You should have received a copy of the GNU General Public License + * along with Patchage. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef PATCHAGE_TEXTVIEWLOG_HPP +#define PATCHAGE_TEXTVIEWLOG_HPP + +#include "ILog.hpp" +#include "Widget.hpp" + +#include <glibmm/refptr.h> +#include <gtkmm/texttag.h> +#include <gtkmm/textview.h> + +/// Log that writes colored messages to a Gtk TextView +class TextViewLog : public ILog +{ +public: + explicit TextViewLog(Widget<Gtk::TextView>& text_view); + + TextViewLog(const TextViewLog&) = delete; + TextViewLog& operator=(const TextViewLog&) = delete; + + TextViewLog(TextViewLog&&) = delete; + TextViewLog& operator=(TextViewLog&&) = delete; + + ~TextViewLog() override = default; + + void info_msg(const std::string& msg) override; + void error_msg(const std::string& msg) override; + void warning_msg(const std::string& msg) override; + + int min_height() const; + + const Widget<Gtk::TextView>& text_view() const { return _text_view; } + Widget<Gtk::TextView>& text_view() { return _text_view; } + +private: + Glib::RefPtr<Gtk::TextTag> _error_tag; + Glib::RefPtr<Gtk::TextTag> _warning_tag; + Widget<Gtk::TextView>& _text_view; +}; + +#endif // PATCHAGE_TEXTVIEWLOG_HPP |