Fawkes API
Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * logview.h - Fawkes log view widget 00004 * 00005 * Created: Mon Nov 02 13:08:29 2008 00006 * Copyright 2008 Tim Niemueller [www.niemueller.de] 00007 * 00008 ****************************************************************************/ 00009 00010 /* This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. A runtime exception applies to 00014 * this software (see LICENSE.GPL_WRE file mentioned below for details). 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Library General Public License for more details. 00020 * 00021 * Read the full text in the LICENSE.GPL_WRE file in the doc directory. 00022 */ 00023 00024 #ifndef __LIBS_GUI_UTILS_LOGVIEW_H_ 00025 #define __LIBS_GUI_UTILS_LOGVIEW_H_ 00026 00027 #include <gtkmm.h> 00028 00029 #include <logging/logger.h> 00030 00031 namespace fawkes { 00032 #if 0 /* just to make Emacs auto-indent happy */ 00033 } 00034 #endif 00035 00036 class FawkesNetworkClient; 00037 class FawkesNetworkMessage; 00038 class ConnectionDispatcher; 00039 00040 class LogView 00041 : public Gtk::TreeView 00042 { 00043 public: 00044 LogView(); 00045 LogView(const char *hostname, unsigned short int port); 00046 LogView(BaseObjectType* cobject, 00047 const Glib::RefPtr<Gtk::Builder> &builder); 00048 ~LogView(); 00049 00050 void set_client(FawkesNetworkClient *client); 00051 FawkesNetworkClient * get_client(); 00052 00053 void append_message(Logger::LogLevel log_level, struct timeval t, 00054 const char *component, bool is_exception, 00055 const char *message); 00056 00057 void clear(); 00058 00059 ConnectionDispatcher * get_connection_dispatcher() const; 00060 00061 private: 00062 virtual void on_row_inserted(const Gtk::TreeModel::Path& path, 00063 const Gtk::TreeModel::iterator& iter); 00064 virtual void on_message_received(FawkesNetworkMessage *msg); 00065 virtual void on_client_connected(); 00066 virtual void on_client_disconnected(); 00067 #if GTK_VERSION_GE(3,0) 00068 virtual bool on_draw(const Cairo::RefPtr<Cairo::Context> &cr); 00069 #else 00070 virtual void on_expose_notify(GdkEventExpose *event); 00071 #endif 00072 00073 void ctor(const char *hostname = NULL, unsigned short int port = 0); 00074 00075 private: 00076 class LogRecord : public Gtk::TreeModelColumnRecord 00077 { 00078 public: 00079 LogRecord(); 00080 00081 /// @cond INTERNALS 00082 Gtk::TreeModelColumn<Glib::ustring> loglevel; 00083 Gtk::TreeModelColumn<Glib::ustring> time; 00084 Gtk::TreeModelColumn<Glib::ustring> component; 00085 Gtk::TreeModelColumn<Glib::ustring> message; 00086 Gtk::TreeModelColumn<Gdk::Color> foreground; 00087 Gtk::TreeModelColumn<Gdk::Color> background; 00088 /// @endcond 00089 }; 00090 00091 LogRecord __record; 00092 00093 Glib::RefPtr<Gtk::ListStore> __list; 00094 00095 ConnectionDispatcher *__connection_dispatcher; 00096 FawkesNetworkClient *__client; 00097 00098 bool __have_recently_added_path; 00099 Gtk::TreeModel::Path __recently_added_path; 00100 }; 00101 00102 } // end namespace fawkes 00103 00104 00105 #endif