diff options
-rw-r--r-- | src/gui/buddywindow.cpp | 12 | ||||
-rw-r--r-- | src/gui/chat.cpp | 6 | ||||
-rw-r--r-- | src/gui/chat.h | 3 | ||||
-rw-r--r-- | src/resources/buddylist.cpp | 7 |
4 files changed, 24 insertions, 4 deletions
diff --git a/src/gui/buddywindow.cpp b/src/gui/buddywindow.cpp index 748ecb97..d2a20ffe 100644 --- a/src/gui/buddywindow.cpp +++ b/src/gui/buddywindow.cpp @@ -24,6 +24,9 @@ #include "buddywindow.h" #include "scrollarea.h" #include "button.h" +#include "chat.h" + +extern ChatWindow *chatWindow; BuddyWindow::BuddyWindow(): Window("Buddy") @@ -35,7 +38,7 @@ BuddyWindow::BuddyWindow(): scrollArea = new ScrollArea(listbox); scrollArea->setDimension(gcn::Rectangle( - 2, 0, 116, 180)); + 2, 0, 114, 176)); add(scrollArea); talk = new Button("Talk"); @@ -68,7 +71,12 @@ BuddyWindow::~BuddyWindow() void BuddyWindow::action(const std::string& eventId) { if (eventId == "Talk") { - // TODO + int selected = listbox->getSelected(); + if ( selected > -1 ) + { + std::string who = getElementAt(selected); + chatWindow->setInputText(who +": "); + } } else if (eventId == "Remove") { int selected = listbox->getSelected(); diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 8a11969a..c02f5160 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -327,3 +327,9 @@ void ChatWindow::keyPress(const gcn::Key &key) chatInput->setCaretPosition(chatInput->getText().length()); } } + +void ChatWindow::setInputText(std::string input_str) +{ + chatInput->setText(input_str + " "); + requestChatFocus(); +} diff --git a/src/gui/chat.h b/src/gui/chat.h index dfb0ba85..f459b804 100644 --- a/src/gui/chat.h +++ b/src/gui/chat.h @@ -184,6 +184,9 @@ class ChatWindow : public Window, public gcn::ActionListener, /** Called when key is pressed */ void keyPress(const gcn::Key& key); + /** Called to set current text */ + void setInputText(std::string input_str); + private: std::ofstream chatlog_file; diff --git a/src/resources/buddylist.cpp b/src/resources/buddylist.cpp index 9772ff19..9f11b5f7 100644 --- a/src/resources/buddylist.cpp +++ b/src/resources/buddylist.cpp @@ -42,7 +42,7 @@ BuddyList::~BuddyList() void BuddyList::loadFile(void) { - char buddy[LEN_USERNAME]; + char *buddy; // Open file std::ifstream inputStream(filename->c_str(), std::ios::in); @@ -52,8 +52,11 @@ void BuddyList::loadFile(void) } do { + buddy = (char *) calloc(LEN_USERNAME, sizeof(char)); inputStream.getline(buddy, LEN_USERNAME); - buddylist.push_back(buddy); + // Ugly ? + if(strcmp(buddy,"") != 0) buddylist.push_back(buddy); + free(buddy); } while(!inputStream.eof()); // Read buddy and close file |