Changeset 4ab49e4578dd3587e295b8b27fb5b532d4a140c5

Show
Ignore:
Timestamp:
01/06/07 23:28:21 (6 years ago)
Author:
Philipp Kern <phil@…>
Parents:
c40b98ab109bd871aae7bc307c981541a48f88b5
Children:
7d6376a1a8f3b6bbe625db18ac669845b63da897
git-committer:
Philipp Kern <phil@0x539.de> / 2007-01-06T22:28:21Z+0000
Message:

[project @ Added handling of chat events from m_chat and m_buffer]

Original author: Benjamin Herr <ben@…>
Date: 2005-04-07 11:49:23+00:00

Files:
4 modified

Legend:

Unmodified
Added
Removed
  • inc/chat.hpp

    rdb674f7 r4ab49e4  
    4949        void obby_document_insert(obby::document& document); 
    5050        void obby_document_remove(obby::document& document); 
     51  void obby_message(obby::user& user, const Glib::ustring& message); 
     52  void obby_server_message(const Glib::ustring& message); 
    5153protected: 
    5254        void on_chat(); 
  • inc/window.hpp

    rdb674f7 r4ab49e4  
    4545        void on_quit(); 
    4646 
     47  void on_chat(const Glib::ustring& message); 
     48 
    4749        // Obby signal handlers 
    4850        void on_obby_login_failed(const std::string& reason); 
     
    5456        void on_obby_document_insert(obby::document& document); 
    5557        void on_obby_document_remove(obby::document& document); 
     58 
     59  void on_obby_server_chat(const Glib::ustring& message); 
     60  void on_obby_chat(obby::user& user, const Glib::ustring& message); 
    5661 
    5762        bool on_timer(); 
  • src/chat.cpp

    rdb674f7 r4ab49e4  
    9191} 
    9292 
     93void Gobby::Chat::obby_message(obby::user& user, const Glib::ustring& message) 
     94{ 
     95  m_log_chat.log("<" + user.get_name() + "> " + message, "black"); 
     96} 
     97 
     98void Gobby::Chat::obby_server_message(const Glib::ustring& message) { 
     99  m_log_chat.log(message, "forest green"); 
     100} 
     101 
    93102void Gobby::Chat::on_chat() 
    94103{ 
  • src/window.cpp

    rdb674f7 r4ab49e4  
    1717 */ 
    1818 
     19#include <stdexcept> 
    1920#include <gtkmm/main.h> 
    2021#include <gtkmm/messagedialog.h> 
     
    3839        m_header.quit_event().connect( 
    3940                sigc::mem_fun(*this, &Window::on_quit) ); 
     41 
     42  m_chat.chat_event().connect( 
     43    sigc::mem_fun(*this, &Window::on_chat) ); 
    4044 
    4145        m_frame_chat.set_shadow_type(Gtk::SHADOW_IN); 
     
    97101                m_buffer->remove_document_event().connect( 
    98102                        sigc::mem_fun(*this, &Window::on_obby_document_remove)); 
     103 
     104    m_buffer->message_event().connect( 
     105      sigc::mem_fun(*this, &Window::on_obby_chat) ); 
     106    m_buffer->server_message_event().connect( 
     107      sigc::mem_fun(*this, &Window::on_obby_server_chat) ); 
     108 
    99109 
    100110                if(!m_timer_conn.connected() ) 
     
    226236} 
    227237 
     238void Gobby::Window::on_chat(const Glib::ustring& message) { 
     239  if (m_running) 
     240    m_buffer->send_message(message); 
     241  else 
     242    throw std::runtime_error("tried to send chat message while not connected"); 
     243} 
     244 
    228245void Gobby::Window::on_obby_login_failed(const std::string& reason) 
    229246{ 
     
    259276} 
    260277 
     278void Gobby::Window::on_obby_chat(obby::user& user, const Glib::ustring& message) 
     279{ 
     280  m_chat.obby_message(user, message); 
     281} 
     282 
     283void Gobby::Window::on_obby_server_chat(const Glib::ustring& message) 
     284{ 
     285  m_chat.obby_server_message(message); 
     286} 
     287 
     288 
     289 
    261290bool Gobby::Window::on_timer() 
    262291{