1 /** @file
2 * @brief Whiteboard share with chatroom dialog - implementation
3 */
4 /* Authors:
5 * David Yip <yipdw@rose-hulman.edu>
6 * Jason Segal
7 * Jonas Collaros
8 * Stephen Montgomery
9 * Brandi Soggs
10 * Matthew Weinstock (original C/Gtk version)
11 *
12 * Copyright (c) 2004-2005 Authors
13 * Released under GNU GPL, read the file 'COPYING' for more information
14 */
16 #include <glibmm/i18n.h>
18 #include <sigc++/sigc++.h>
19 #include <gtk/gtkdialog.h>
21 #include "message-stack.h"
22 #include "message-context.h"
23 #include "inkscape.h"
24 #include "desktop.h"
26 #include "preferences.h"
28 #include "jabber_whiteboard/typedefs.h"
29 #include "jabber_whiteboard/session-manager.h"
30 #include "jabber_whiteboard/buddy-list-manager.h"
32 #include "jabber_whiteboard/session-file-selector.h"
34 #include "ui/dialog/whiteboard-sharewithchat.h"
36 #include "util/ucompose.hpp"
38 namespace Inkscape {
39 namespace UI {
40 namespace Dialog {
42 WhiteboardShareWithChatroomDialog*
43 WhiteboardShareWithChatroomDialog::create()
44 {
45 return new WhiteboardShareWithChatroomDialogImpl();
46 }
48 WhiteboardShareWithChatroomDialogImpl::WhiteboardShareWithChatroomDialogImpl() :
49 _layout(4, 2, false)
50 {
51 this->setSessionManager();
52 this->_construct();
53 this->get_vbox()->show_all_children();
54 }
56 WhiteboardShareWithChatroomDialogImpl::~WhiteboardShareWithChatroomDialogImpl()
57 {
59 }
61 void
62 WhiteboardShareWithChatroomDialogImpl::setSessionManager()
63 {
64 this->_desktop = this->getDesktop();
65 this->_sm = this->_desktop->whiteboard_session_manager();
67 }
70 void
71 WhiteboardShareWithChatroomDialogImpl::_construct()
72 {
73 Gtk::VBox* main = this->get_vbox();
75 // Construct labels
76 this->_labels[0].set_markup_with_mnemonic(_("Chatroom _name:"));
77 this->_labels[1].set_markup_with_mnemonic(_("Chatroom _server:"));
78 this->_labels[2].set_markup_with_mnemonic(_("Chatroom _password:"));
79 this->_labels[3].set_markup_with_mnemonic(_("Chatroom _handle:"));
81 this->_labels[0].set_mnemonic_widget(this->_roomname);
82 this->_labels[1].set_mnemonic_widget(this->_confserver);
83 this->_labels[2].set_mnemonic_widget(this->_roompass);
84 this->_labels[3].set_mnemonic_widget(this->_handle);
86 Inkscape::Preferences *prefs = Inkscape::Preferences::get();
87 this->_roomname.set_text(prefs->getString("/whiteboard/room/name"));
88 this->_confserver.set_text(prefs->getString("/whiteboard/room/server"));
89 this->_handle.set_text(prefs->getString("/whiteboard/server/username"));
91 // Pack table
92 this->_layout.attach(this->_labels[0], 0, 1, 0, 1);
93 this->_layout.attach(this->_labels[1], 0, 1, 1, 2);
94 this->_layout.attach(this->_labels[2], 0, 1, 2, 3);
95 this->_layout.attach(this->_labels[3], 0, 1, 3, 4);
97 this->_layout.attach(this->_roomname, 1, 2, 0, 1);
98 this->_layout.attach(this->_confserver, 1, 2, 1, 2);
99 this->_layout.attach(this->_roompass, 1, 2, 2, 3);
100 this->_layout.attach(this->_handle, 1, 2, 3, 4);
102 // Button setup and callback registration
103 this->_share.set_label(_("Connect to chatroom"));
104 this->_cancel.set_label(_("Cancel"));
105 this->_share.set_use_underline(true);
106 this->_cancel.set_use_underline(true);
108 this->_share.signal_clicked().connect(sigc::bind< 0 >(sigc::mem_fun(*this, &WhiteboardShareWithChatroomDialogImpl::_respCallback), WhiteboardShareWithChatroomDialogImpl::SHARE));
109 this->_cancel.signal_clicked().connect(sigc::bind< 0 >(sigc::mem_fun(*this, &WhiteboardShareWithChatroomDialogImpl::_respCallback), WhiteboardShareWithChatroomDialogImpl::CANCEL));
111 // Pack buttons
112 this->_buttonsbox.pack_start(this->_cancel);
113 this->_buttonsbox.pack_start(this->_share);
115 // Set default values
116 Glib::ustring jid = this->_sm->session_data->jid;
117 Glib::ustring nick = jid.substr(0, jid.find_first_of('@'));
118 this->_handle.set_text(nick);
119 this->_roomname.set_text("inkboard");
121 // Pack into main box
122 main->pack_start(this->_layout);
123 main->pack_end(this->_buttonsbox);
124 }
126 void
127 WhiteboardShareWithChatroomDialogImpl::_respCallback(int resp)
128 {
129 switch (resp) {
130 case SHARE:
131 {
132 Glib::ustring chatroom, server, handle, password;
133 chatroom = this->_roomname.get_text();
134 server = this->_confserver.get_text();
135 password = this->_roompass.get_text();
136 handle = this->_handle.get_text();
138 Glib::ustring msg = String::ucompose(_("Synchronizing with chatroom <b>%1@%2</b> using the handle <b>%3</b>"), chatroom, server, handle);
140 this->_desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, msg.data());
142 this->_desktop->whiteboard_session_manager()->sendRequestToChatroom(server, chatroom, handle, password);
143 }
144 case CANCEL:
145 default:
146 this->hide();
147 break;
148 }
149 }
151 } // namespace Dialog
152 } // namespace UI
153 } // namespace Inkscape
155 /*
156 Local Variables:
157 mode:c++
158 c-file-style:"stroustrup"
159 c-file-offsets:((innamespace . 0)(inline-open . 0))
160 indent-tabs-mode:nil
161 fill-column:99
162 End:
163 */
164 // vim: expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :