logview.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __LIBS_GUI_UTILS_LOGVIEW_H_
00025 #define __LIBS_GUI_UTILS_LOGVIEW_H_
00026
00027 #include <gtkmm.h>
00028 #ifdef HAVE_GLADEMM
00029 # include <libglademm/xml.h>
00030 #endif
00031
00032 #include <utils/logging/logger.h>
00033
00034 namespace fawkes {
00035 #if 0
00036 }
00037 #endif
00038
00039 class FawkesNetworkClient;
00040 class FawkesNetworkMessage;
00041 class ConnectionDispatcher;
00042
00043 class LogView
00044 : public Gtk::TreeView
00045 {
00046 public:
00047 LogView();
00048 LogView(const char *hostname, unsigned short int port);
00049 #ifdef HAVE_GLADEMM
00050 LogView(BaseObjectType* cobject,
00051 const Glib::RefPtr<Gnome::Glade::Xml>& ref_glade);
00052 #endif
00053 ~LogView();
00054
00055 void set_client(FawkesNetworkClient *client);
00056 FawkesNetworkClient * get_client();
00057
00058 void append_message(Logger::LogLevel log_level, struct timeval t,
00059 const char *component, bool is_exception,
00060 const char *message);
00061
00062 void clear();
00063
00064 ConnectionDispatcher * get_connection_dispatcher() const;
00065
00066 private:
00067 virtual void on_row_inserted(const Gtk::TreeModel::Path& path,
00068 const Gtk::TreeModel::iterator& iter);
00069 virtual void on_message_received(FawkesNetworkMessage *msg);
00070 virtual void on_client_connected();
00071 virtual void on_client_disconnected();
00072 virtual void on_expose_notify(GdkEventExpose *event);
00073
00074 void ctor(const char *hostname = NULL, unsigned short int port = 0);
00075
00076 private:
00077 class LogRecord : public Gtk::TreeModelColumnRecord
00078 {
00079 public:
00080 LogRecord();
00081 Gtk::TreeModelColumn<Glib::ustring> loglevel;
00082 Gtk::TreeModelColumn<Glib::ustring> time;
00083 Gtk::TreeModelColumn<Glib::ustring> component;
00084 Gtk::TreeModelColumn<Glib::ustring> message;
00085 Gtk::TreeModelColumn<Gdk::Color> foreground;
00086 Gtk::TreeModelColumn<Gdk::Color> background;
00087 };
00088
00089 LogRecord __record;
00090
00091 Glib::RefPtr<Gtk::ListStore> __list;
00092
00093 ConnectionDispatcher *__connection_dispatcher;
00094 FawkesNetworkClient *__client;
00095
00096 bool __have_recently_added_path;
00097 Gtk::TreeModel::Path __recently_added_path;
00098 };
00099
00100 }
00101
00102
00103 #endif