logview.h

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 #ifdef HAVE_GLADEMM
00029 #  include <libglademm/xml.h>
00030 #endif
00031 
00032 #include <utils/logging/logger.h>
00033 
00034 namespace fawkes {
00035 #if 0 /* just to make Emacs auto-indent happy */
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 } // end namespace fawkes
00101 
00102 
00103 #endif

Generated on Tue Feb 22 13:32:27 2011 for Fawkes API by  doxygen 1.4.7