Fawkes API  Fawkes Development Version
logview.h
1 
2 /***************************************************************************
3  * logview.h - Fawkes log view widget
4  *
5  * Created: Mon Nov 02 13:08:29 2008
6  * Copyright 2008 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #ifndef _LIBS_GUI_UTILS_LOGVIEW_H_
25 #define _LIBS_GUI_UTILS_LOGVIEW_H_
26 
27 #include <logging/logger.h>
28 
29 #include <gtkmm.h>
30 
31 namespace fawkes {
32 
33 class FawkesNetworkClient;
34 class FawkesNetworkMessage;
35 class ConnectionDispatcher;
36 
37 class LogView : public Gtk::TreeView
38 {
39 public:
40  LogView();
41  LogView(const char *hostname, unsigned short int port);
42  LogView(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &builder);
43  ~LogView();
44 
45  void set_client(FawkesNetworkClient *client);
47 
48  void append_message(Logger::LogLevel log_level,
49  struct timeval t,
50  const char * component,
51  bool is_exception,
52  const char * message);
53 
54  void clear();
55 
57 
58 private:
59  virtual void on_row_inserted(const Gtk::TreeModel::Path & path,
60  const Gtk::TreeModel::iterator &iter);
61  virtual void on_message_received(FawkesNetworkMessage *msg);
62  virtual void on_client_connected();
63  virtual void on_client_disconnected();
64 #if GTK_VERSION_GE(3, 0)
65  virtual bool on_draw(const Cairo::RefPtr<Cairo::Context> &cr);
66 #else
67  virtual void on_expose_notify(GdkEventExpose *event);
68 #endif
69 
70  void ctor(const char *hostname = NULL, unsigned short int port = 0);
71 
72 private:
73  class LogRecord : public Gtk::TreeModelColumnRecord
74  {
75  public:
76  LogRecord();
77 
78  /// @cond INTERNALS
79  Gtk::TreeModelColumn<Glib::ustring> loglevel;
80  Gtk::TreeModelColumn<Glib::ustring> time;
81  Gtk::TreeModelColumn<Glib::ustring> component;
82  Gtk::TreeModelColumn<Glib::ustring> message;
83  Gtk::TreeModelColumn<Gdk::Color> foreground;
84  Gtk::TreeModelColumn<Gdk::Color> background;
85  /// @endcond
86  };
87 
88  LogRecord record_;
89 
90  Glib::RefPtr<Gtk::ListStore> list_;
91 
92  ConnectionDispatcher *connection_dispatcher_;
93 
94  bool have_recently_added_path_;
95  Gtk::TreeModel::Path recently_added_path_;
96 };
97 
98 } // end namespace fawkes
99 
100 #endif
fawkes::LogView::append_message
void append_message(Logger::LogLevel log_level, struct timeval t, const char *component, bool is_exception, const char *message)
Append a single message.
Definition: logview.cpp:259
fawkes::LogView::get_client
FawkesNetworkClient * get_client()
Get the used FawkesNetworkClient.
Definition: logview.cpp:169
fawkes::ConnectionDispatcher
Watches network client events and dispatches them as signals.
Definition: connection_dispatcher.h:39
fawkes
Fawkes library namespace.
fawkes::LogView::set_client
void set_client(FawkesNetworkClient *client)
Set FawkesNetworkClient instance.
Definition: logview.cpp:149
fawkes::Logger::LogLevel
LogLevel
Log level.
Definition: logger.h:51
fawkes::FawkesNetworkMessage
Representation of a message that is sent over the network.
Definition: message.h:77
fawkes::LogView::~LogView
~LogView()
Destructor.
Definition: logview.cpp:67
fawkes::LogView::clear
void clear()
Clear all records.
Definition: logview.cpp:185
fawkes::FawkesNetworkClient
Simple Fawkes network client.
Definition: client.h:52
fawkes::LogView
Log View widget.
Definition: logview.h:38
fawkes::LogView::get_connection_dispatcher
ConnectionDispatcher * get_connection_dispatcher() const
Get ConnectionDispatcher instance that is used internally.
Definition: logview.cpp:178
fawkes::LogView::LogView
LogView()
Constructor.
Definition: logview.cpp:41