Changeset debf4abb25a94c2355deabff93cc6d1398ac7278
- Timestamp:
- 01/06/07 23:59:02 (6 years ago)
- Parents:
- 8975b6e0f22d55b275ae4beeab91bec67a2d5bbb
- Children:
- 50fd8625a91817104b85ce1f4f61945dd3a73274
- git-committer:
- Philipp Kern <phil@0x539.de> / 2007-01-06T22:59:02Z+0000
- Files:
-
- 2 removed
- 16 modified
-
Makefile.am (modified) (2 diffs)
-
inc/defaultdialog.hpp (deleted)
-
inc/entrydialog.hpp (modified) (1 diff)
-
inc/hostdialog.hpp (modified) (2 diffs)
-
inc/joindialog.hpp (modified) (2 diffs)
-
inc/joinprogressdialog.hpp (modified) (1 diff)
-
inc/passworddialog.hpp (modified) (3 diffs)
-
src/buffer_def.cpp (modified) (1 diff)
-
src/defaultdialog.cpp (deleted)
-
src/document.cpp (modified) (1 diff)
-
src/docwindow.cpp (modified) (1 diff)
-
src/entrydialog.cpp (modified) (3 diffs)
-
src/fileentry.cpp (modified) (3 diffs)
-
src/hostdialog.cpp (modified) (3 diffs)
-
src/joindialog.cpp (modified) (3 diffs)
-
src/joinprogressdialog.cpp (modified) (9 diffs)
-
src/passworddialog.cpp (modified) (4 diffs)
-
src/window.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
Makefile.am
r84c0261 rdebf4ab 24 24 noinst_HEADERS += inc/application_state.hpp 25 25 noinst_HEADERS += inc/encoding_selector.hpp 26 noinst_HEADERS += inc/defaultdialog.hpp27 26 noinst_HEADERS += inc/historyentry.hpp 28 27 noinst_HEADERS += inc/fileentry.hpp … … 78 77 gobby_SOURCES += src/application_state.cpp 79 78 gobby_SOURCES += src/encoding_selector.cpp 80 gobby_SOURCES += src/defaultdialog.cpp81 79 gobby_SOURCES += src/historyentry.cpp 82 80 gobby_SOURCES += src/fileentry.cpp -
inc/entrydialog.hpp
rdb38fa5 rdebf4ab 22 22 #include <gtkmm/label.h> 23 23 #include <gtkmm/entry.h> 24 #include "defaultdialog.hpp"24 #include <gtkmm/dialog.h> 25 25 26 26 namespace Gobby 27 27 { 28 28 29 class EntryDialog : public DefaultDialog29 class EntryDialog: public Gtk::Dialog 30 30 { 31 31 public: -
inc/hostdialog.hpp
rb6b3405 rdebf4ab 25 25 #include <gtkmm/entry.h> 26 26 #include <gtkmm/colorbutton.h> 27 #include "defaultdialog.hpp"28 27 #include "colorsel.hpp" 29 28 #include "config.hpp" … … 33 32 { 34 33 35 class HostDialog : public DefaultDialog34 class HostDialog: public Gtk::Dialog 36 35 { 37 36 public: -
inc/joindialog.hpp
r2292265 rdebf4ab 25 25 #include <gtkmm/entry.h> 26 26 #include <gtkmm/colorbutton.h> 27 #include "defaultdialog.hpp"28 27 #include "config.hpp" 29 28 #include "features.hpp" … … 42 41 { 43 42 44 class JoinDialog : public DefaultDialog43 class JoinDialog: public Gtk::Dialog 45 44 { 46 45 public: 47 46 #ifdef WITH_HOWL 48 class Columns : public Gtk::TreeModel::ColumnRecord47 class Columns: public Gtk::TreeModel::ColumnRecord 49 48 { 50 49 public: -
inc/joinprogressdialog.hpp
r882c708 rdebf4ab 46 46 typedef ClientBuffer::connection_settings connection_settings; 47 47 48 class Prompt: public DefaultDialog48 class Prompt: public Gtk::Dialog 49 49 { 50 p ublic:50 protected: 51 51 Prompt(Gtk::Window& parent, 52 52 const Glib::ustring& title, 53 53 const Glib::ustring& info, 54 Gtk::Widget& widget,55 54 const Gtk::StockID& icon); 56 protected: 55 56 void set_custom_widget(Widget& widget); 57 57 58 Gtk::Table m_table; 58 59 Gtk::Label m_info; 59 60 Gtk::Image m_icon; 61 }; 62 63 class NamePrompt: public Prompt 64 { 65 public: 66 NamePrompt(Gtk::Window& parent, 67 const Glib::ustring& initial_name); 68 69 Glib::ustring get_name() const; 70 protected: 71 void on_change(); 72 73 const Glib::ustring m_initial_name; 74 75 Gtk::HBox m_box; 76 Gtk::Label m_label; 77 Gtk::Entry m_entry; 78 }; 79 80 class ColorPrompt: public Prompt 81 { 82 public: 83 ColorPrompt(Gtk::Window& parent, 84 const Gdk::Color& initial_color); 85 86 Gdk::Color get_color() const; 87 protected: 88 Gtk::ColorButton m_button; 89 }; 90 91 class SessionPasswordPrompt: public Prompt 92 { 93 public: 94 SessionPasswordPrompt(Gtk::Window& parent); 95 96 Glib::ustring get_password() const; 97 protected: 98 void on_change(); 99 100 Gtk::HBox m_box; 101 Gtk::Label m_label; 102 Gtk::Entry m_entry; 103 }; 104 105 class UserPasswordPrompt: public Prompt 106 { 107 public: 108 UserPasswordPrompt(Gtk::Window& parent, 109 const Glib::ustring& initial_name); 110 111 Glib::ustring get_name() const; 112 Glib::ustring get_password() const; 113 protected: 114 void on_change(); 115 116 const Glib::ustring m_initial_name; 117 118 Gtk::Table m_table; 119 Gtk::Label m_lbl_name; 120 Gtk::Label m_lbl_password; 121 Gtk::Entry m_ent_name; 122 Gtk::Entry m_ent_password; 60 123 }; 61 124 -
inc/passworddialog.hpp
r1662ea7 rdebf4ab 20 20 #define _GOBBY_PASSWORDDIALOG_HPP_ 21 21 22 #include "defaultdialog.hpp"23 22 #include <gtkmm/table.h> 24 23 #include <gtkmm/label.h> … … 29 28 { 30 29 31 class PasswordDialog : public DefaultDialog30 class PasswordDialog: public Gtk::Dialog 32 31 { 33 32 public: 34 PasswordDialog(Gtk::Window& parent, const Glib::ustring& title, 35 bool request); 36 ~PasswordDialog(); 33 PasswordDialog(Gtk::Window& parent, const Glib::ustring& title); 37 34 38 35 void set_info(const Glib::ustring& info); … … 40 37 protected: 41 38 void on_password_changed(); 42 43 bool m_request;44 39 45 40 Gtk::Table m_table; -
src/buffer_def.cpp
rba89078 rdebf4ab 34 34 bool Gobby::is_subscribable(const LocalDocumentInfo& info) 35 35 { 36 // Gobby only allow subscriptions to UTF-8 encoded documents36 // Gobby only allows subscriptions to UTF-8 encoded documents 37 37 for(std::size_t n = 0; n < utf8_repr_count; ++ n) 38 38 if(info.get_encoding() == utf8_reprs[n]) -
src/document.cpp
r124a20e rdebf4ab 242 242 ); 243 243 244 // TODO: This belongs to document 245 m_buffer->begin_not_undoable_action(); 246 244 247 // TODO: Connect to user table's signal handler - as soon as it 245 248 // has some... -
src/docwindow.cpp
ra8762fa rdebf4ab 57 57 m_view.set_buffer(buf); 58 58 59 // TODO: This belongs to document60 buf->begin_not_undoable_action();61 62 59 // Set source language by filename 63 60 buf->set_highlight(false); -
src/entrydialog.cpp
rdb38fa5 rdebf4ab 23 23 Gobby::EntryDialog::EntryDialog(Gtk::Window& parent, 24 24 const Glib::ustring& title, 25 const Glib::ustring& label) 26 : DefaultDialog(title, parent, true, true), 27 m_label(label), 28 m_box(false, 5), 29 m_check_valid_entry(false) 25 const Glib::ustring& label): 26 Gtk::Dialog(title, parent, true, true), m_label(label), m_box(false, 5), 27 m_check_valid_entry(false) 30 28 { 29 m_entry.set_activates_default(true); 30 31 31 m_box.pack_start(m_label); 32 32 m_box.pack_start(m_entry); … … 35 35 get_vbox()->pack_start(m_box); 36 36 37 set_default_response(Gtk::RESPONSE_OK); 37 m_entry.signal_changed().connect( 38 sigc::mem_fun(*this, &EntryDialog::on_entry_changed) 39 ); 38 40 39 41 add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); 40 42 add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK); 41 42 m_entry.signal_changed().connect( 43 sigc::mem_fun(*this, &EntryDialog::on_entry_changed) ); 43 set_default_response(Gtk::RESPONSE_OK); 44 44 45 45 show_all(); … … 86 86 set_response_sensitive(Gtk::RESPONSE_OK, !disable); 87 87 } 88 -
src/fileentry.cpp
r3bec576 rdebf4ab 21 21 22 22 Gobby::FileEntry::FileEntry(const Glib::ustring& title): 23 Gtk::HBox(), m_ dialog(title), m_btn_browse(Gtk::Stock::OPEN)23 Gtk::HBox(), m_btn_browse(Gtk::Stock::OPEN), m_dialog(title) 24 24 { 25 25 init(); … … 27 27 28 28 Gobby::FileEntry::FileEntry(Gtk::Window& parent, const Glib::ustring& title): 29 Gtk::HBox(), m_ dialog(parent, title), m_btn_browse(Gtk::Stock::OPEN)29 Gtk::HBox(), m_btn_browse(Gtk::Stock::OPEN), m_dialog(parent, title) 30 30 { 31 31 init(); … … 38 38 39 39 m_btn_browse.signal_clicked().connect( 40 sigc::mem_fun(*this, &FileEntry::on_browse) ); 40 sigc::mem_fun(*this, &FileEntry::on_browse) 41 ); 41 42 42 43 pack_start(m_ent_file, Gtk::PACK_EXPAND_WIDGET); 43 44 pack_start(m_btn_browse, Gtk::PACK_SHRINK); 45 46 m_ent_file.set_activates_default(true); 44 47 45 48 set_spacing(5); -
src/hostdialog.cpp
r67b341e rdebf4ab 22 22 23 23 Gobby::HostDialog::HostDialog(Gtk::Window& parent, Config& config): 24 DefaultDialog(_("Create obby session"), parent, true, true),24 Gtk::Dialog(_("Create obby session"), parent, true, true), 25 25 m_config(config), 26 26 m_table(4, 2), … … 51 51 m_ent_name.set_text(name); 52 52 m_btn_color.set_color(color); 53 54 sigc::slot<void> response( 55 sigc::bind( 56 sigc::mem_fun(*this, &Gtk::Dialog::response), 57 Gtk::RESPONSE_OK 58 ) 59 ); 60 61 m_ent_port.set_activates_default(true); 62 m_ent_name.set_activates_default(true); 63 m_ent_password.set_activates_default(true); 53 64 54 65 m_table.attach(m_lbl_port, 0, 1, 0, 1, … … 93 104 add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); 94 105 Gtk::Button* host_btn = add_button(_("_Host"), Gtk::RESPONSE_OK); 106 95 107 Gtk::Image* img = Gtk::manage( 96 108 new Gtk::Image(Gtk::Stock::NETWORK, Gtk::ICON_SIZE_BUTTON) 97 ); 109 ); 110 98 111 host_btn->set_image(*img); 112 113 set_default_response(Gtk::RESPONSE_OK); 99 114 100 115 show_all(); -
src/joindialog.cpp
rcd79074 rdebf4ab 32 32 33 33 #ifndef WITH_HOWL 34 Gobby::JoinDialog::JoinDialog(Gtk::Window& parent, Gobby::Config& config) 34 Gobby::JoinDialog::JoinDialog(Gtk::Window& parent, Gobby::Config& config): 35 35 #else 36 36 Gobby::JoinDialog::JoinDialog(Gtk::Window& parent, Gobby::Config& config, 37 obby::zeroconf* zeroconf) 38 #endif 39 : DefaultDialog(_("Join obby session"), parent, true, true),37 obby::zeroconf* zeroconf): 38 #endif 39 Gtk::Dialog(_("Join obby session"), parent, true, true), 40 40 m_config(config), 41 41 m_table(4, 2), … … 71 71 m_ent_name.set_text(name); 72 72 m_btn_color.set_color(color); 73 74 m_ent_host.set_activates_default(true); 75 m_ent_port.set_activates_default(true); 76 m_ent_name.set_activates_default(true); 73 77 74 78 m_table.attach(m_lbl_host, 0, 1, 0, 1, … … 124 128 add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); 125 129 add_button(Gtk::Stock::CONNECT, Gtk::RESPONSE_OK); 130 set_default_response(Gtk::RESPONSE_OK); 126 131 127 132 show_all(); -
src/joinprogressdialog.cpp
r27da386 rdebf4ab 21 21 #include <obby/format_string.hpp> 22 22 #include "common.hpp" 23 #include "defaultdialog.hpp"24 23 #include "colorsel.hpp" 25 24 #include "passworddialog.hpp" … … 27 26 #include "joinprogressdialog.hpp" 28 27 29 namespace { 30 // TODO: How to use std::logical_and and such? 31 bool logical_and(bool lhs, bool rhs) { return lhs && rhs; } 32 bool logical_or(bool lhs, bool rhs) { return lhs || rhs; } 33 bool logical_not(bool arg) { return !arg; } 34 35 typedef bool(*compare_ustring_func)( 36 const Glib::ustring&, 37 const Glib::ustring& 38 ); 28 namespace 29 { 30 Glib::ustring make_user_password_info(const Glib::ustring& username) 31 { 32 obby::format_string str( 33 Gobby::_( 34 "User password for user '%0%' required. You " 35 "may either choose another user name, type " 36 "in your user password or cancel the " 37 "connection." 38 ) 39 ); 40 41 str << username.raw(); 42 return str.str(); 43 } 39 44 40 45 obby::colour gdk_to_obby(const Gdk::Color& color) … … 60 65 const Glib::ustring& title, 61 66 const Glib::ustring& info, 62 Gtk::Widget& widget,63 67 const Gtk::StockID& icon): 64 DefaultDialog(title, parent, true, true), m_table(2, 2), m_info(info),68 Gtk::Dialog(title, parent, true, true), m_table(2, 2), m_info(info), 65 69 m_icon(icon, Gtk::ICON_SIZE_DIALOG) 66 70 { … … 68 72 69 73 m_table.attach(m_icon, 0, 1, 0, 2, Gtk::SHRINK, Gtk::SHRINK); 70 m_table.attach(m_info, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK); 71 m_table.attach(widget, 1, 2, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK); 74 m_table.attach( 75 m_info, 76 1, 2, 0, 1, 77 Gtk::EXPAND | Gtk::FILL, 78 Gtk::SHRINK 79 ); 80 72 81 m_table.set_spacings(10); 73 82 … … 79 88 add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK); 80 89 90 set_default_response(Gtk::RESPONSE_OK); 81 91 set_border_width(10); 82 83 92 set_resizable(false); 93 } 94 95 void Gobby::JoinProgressDialog::Prompt::set_custom_widget(Widget& widget) 96 { 97 m_table.attach( 98 widget, 99 1, 2, 1, 2, 100 Gtk::EXPAND | Gtk::FILL, 101 Gtk::SHRINK 102 ); 103 } 104 105 Gobby::JoinProgressDialog::NamePrompt:: 106 NamePrompt(Gtk::Window& parent, 107 const Glib::ustring& initial_name): 108 Prompt( 109 parent, 110 obby::login::errstring(net6::login::ERROR_NAME_IN_USE), 111 _("Name is already in use. You may choose another name or " 112 "cancel the connection."), 113 Gtk::Stock::DIALOG_QUESTION 114 ), 115 m_initial_name(initial_name), 116 m_label(_("New name:") ) 117 { 118 m_entry.signal_changed().connect( 119 sigc::mem_fun(*this, &NamePrompt::on_change) 120 ); 121 122 m_entry.set_text(m_initial_name); 123 m_entry.set_activates_default(true); 124 125 m_box.pack_start(m_label, Gtk::PACK_SHRINK); 126 m_box.pack_start(m_entry, Gtk::PACK_EXPAND_WIDGET); 127 m_box.set_spacing(10); 128 129 m_box.show_all(); 130 set_custom_widget(m_box); 131 132 m_entry.grab_focus(); 133 } 134 135 Glib::ustring Gobby::JoinProgressDialog::NamePrompt::get_name() const 136 { 137 return m_entry.get_text(); 138 } 139 140 void Gobby::JoinProgressDialog::NamePrompt::on_change() 141 { 142 const Glib::ustring name = m_entry.get_text(); 143 144 set_response_sensitive( 145 Gtk::RESPONSE_OK, 146 name != m_initial_name && !name.empty() 147 ); 148 } 149 150 Gobby::JoinProgressDialog::ColorPrompt:: 151 ColorPrompt(Gtk::Window& parent, 152 const Gdk::Color& initial_color): 153 Prompt( 154 parent, 155 obby::login::errstring(obby::login::ERROR_COLOUR_IN_USE), 156 _("Colour is already in use. You may choose another colour or " 157 "cancel the connection."), 158 Gtk::Stock::DIALOG_QUESTION 159 ) 160 { 161 m_button.set_color(initial_color); 162 m_button.show_all(); 163 164 set_custom_widget(m_button); 165 m_button.grab_focus(); 166 } 167 168 Gdk::Color Gobby::JoinProgressDialog::ColorPrompt::get_color() const 169 { 170 return m_button.get_color(); 171 } 172 173 Gobby::JoinProgressDialog::SessionPasswordPrompt:: 174 SessionPasswordPrompt(Gtk::Window& parent): 175 Prompt( 176 parent, 177 obby::login::errstring( 178 obby::login::ERROR_WRONG_GLOBAL_PASSWORD 179 ), 180 _("Session password required. You have to type in the " 181 "password to be able to join the obby session."), 182 Gtk::Stock::DIALOG_AUTHENTICATION 183 ), 184 m_label(_("Session password:") ) 185 { 186 m_entry.signal_changed().connect( 187 sigc::mem_fun(*this, &SessionPasswordPrompt::on_change) 188 ); 189 190 m_entry.set_activates_default(true); 191 m_entry.set_visibility(false); 192 193 m_box.pack_start(m_label, Gtk::PACK_SHRINK); 194 m_box.pack_start(m_entry, Gtk::PACK_EXPAND_WIDGET); 195 m_box.set_spacing(10); 196 197 m_box.show_all(); 198 set_custom_widget(m_box); 199 set_response_sensitive(Gtk::RESPONSE_OK, false); 200 201 m_entry.grab_focus(); 202 } 203 204 Glib::ustring Gobby::JoinProgressDialog::SessionPasswordPrompt:: 205 get_password() const 206 { 207 return m_entry.get_text(); 208 } 209 210 void Gobby::JoinProgressDialog::SessionPasswordPrompt::on_change() 211 { 212 set_response_sensitive(Gtk::RESPONSE_OK, !m_entry.get_text().empty() ); 213 } 214 215 Gobby::JoinProgressDialog::UserPasswordPrompt:: 216 UserPasswordPrompt(Gtk::Window& parent, 217 const Glib::ustring& initial_name): 218 Prompt( 219 parent, 220 obby::login::errstring(obby::login::ERROR_WRONG_USER_PASSWORD), 221 make_user_password_info(initial_name), 222 Gtk::Stock::DIALOG_AUTHENTICATION 223 ), 224 m_initial_name(initial_name), m_table(2, 2), 225 m_lbl_name(_("New name:"), Gtk::ALIGN_RIGHT), 226 m_lbl_password(_("User password:"), Gtk::ALIGN_RIGHT) 227 { 228 m_ent_name.set_text(m_initial_name); 229 m_ent_password.set_visibility(false); 230 231 m_ent_name.set_activates_default(true); 232 m_ent_password.set_activates_default(true); 233 234 m_ent_name.signal_changed().connect( 235 sigc::mem_fun(*this, &UserPasswordPrompt::on_change) 236 ); 237 238 m_ent_password.signal_changed().connect( 239 sigc::mem_fun(*this, &UserPasswordPrompt::on_change) 240 ); 241 242 m_table.attach( 243 m_lbl_name, 244 0, 1, 0, 1, 245 Gtk::SHRINK, Gtk::SHRINK 246 ); 247 248 m_table.attach( 249 m_lbl_password, 250 0, 1, 1, 2, 251 Gtk::SHRINK, Gtk::SHRINK 252 ); 253 254 m_table.attach( 255 m_ent_name, 256 1, 2, 0, 1, 257 Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK 258 ); 259 260 m_table.attach( 261 m_ent_password, 262 1, 2, 1, 2, 263 Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK 264 ); 265 266 m_table.set_spacings(5); 267 268 set_response_sensitive(Gtk::RESPONSE_OK, false); 269 m_ent_password.grab_focus(); 270 271 m_table.show_all(); 272 set_custom_widget(m_table); 273 274 m_ent_password.grab_focus(); 275 } 276 277 Glib::ustring Gobby::JoinProgressDialog::UserPasswordPrompt::get_name() const 278 { 279 return m_ent_name.get_text(); 280 } 281 282 Glib::ustring Gobby::JoinProgressDialog::UserPasswordPrompt:: 283 get_password() const 284 { 285 return m_ent_password.get_text(); 286 } 287 288 void Gobby::JoinProgressDialog::UserPasswordPrompt::on_change() 289 { 290 const Glib::ustring name = m_ent_name.get_name(); 291 const Glib::ustring password = m_ent_password.get_name(); 292 293 set_response_sensitive( 294 Gtk::RESPONSE_OK, 295 !name.empty() && (name != m_initial_name || !password.empty()) 296 ); 84 297 } 85 298 … … 257 470 bool Gobby::JoinProgressDialog::on_prompt_name(connection_settings& settings) 258 471 { 259 Gtk::HBox box; 260 Gtk::Label label(_("New name:") ); 261 Gtk::Entry entry; 262 entry.set_text(m_username); 263 264 box.pack_start(label, Gtk::PACK_SHRINK); 265 box.pack_start(entry, Gtk::PACK_EXPAND_WIDGET); 266 box.set_spacing(10); 267 268 Prompt prompt( 269 *this, 270 obby::login::errstring(net6::login::ERROR_NAME_IN_USE), 271 _("Name is already in use. You may choose another name or " 272 "cancel the connection."), 273 box, 274 Gtk::Stock::DIALOG_QUESTION 275 ); 276 277 prompt.set_response_sensitive(Gtk::RESPONSE_OK, false); 278 279 // We are using the logical_or and logical_not functions defined above, 280 // but the standard library provides functors like std::logical_or, but 281 // how to use these? 282 sigc::slot<void> changed_slot( 283 sigc::compose( 284 sigc::bind<0>( 285 sigc::mem_fun( 286 prompt, 287 &DefaultDialog::set_response_sensitive 288 ), 289 Gtk::RESPONSE_OK 290 ), 291 sigc::compose( 292 sigc::ptr_fun(&logical_and), 293 sigc::compose( 294 sigc::bind( 295 sigc::ptr_fun(static_cast< 296 compare_ustring_func 297 >(&Glib::operator!=) ), 298 sigc::ref(m_username) 299 ), 300 sigc::mem_fun( 301 entry, 302 &Gtk::Entry::get_text 303 ) 304 ), 305 sigc::compose( 306 sigc::ptr_fun(&logical_not), 307 sigc::compose( 308 &Glib::ustring::empty, 309 sigc::mem_fun( 310 entry, 311 &Gtk::Entry::get_text 312 ) 313 ) 314 ) 315 ) 316 ) 317 ); 318 319 entry.signal_changed().connect(changed_slot); 472 NamePrompt prompt(*this, m_username); 473 320 474 if(prompt.run() == Gtk::RESPONSE_OK) 321 475 { 322 settings.name = entry.get_text();476 settings.name = prompt.get_name(); 323 477 m_username = settings.name; 324 478 return true; … … 333 487 bool Gobby::JoinProgressDialog::on_prompt_colour(connection_settings& settings) 334 488 { 335 ColorButton btn; 336 btn.set_color(m_color); 337 338 Prompt prompt( 339 *this, 340 obby::login::errstring(obby::login::ERROR_COLOUR_IN_USE), 341 _("Colour is already in use. You may choose another colour or " 342 "cancel the connection."), 343 btn, 344 Gtk::Stock::DIALOG_QUESTION 345 ); 346 489 ColorPrompt prompt(*this, m_color); 347 490 if(prompt.run() == Gtk::RESPONSE_OK) 348 491 { 349 settings.colour = gdk_to_obby( btn.get_color() );350 m_color = btn.get_color();492 settings.colour = gdk_to_obby(prompt.get_color() ); 493 m_color = prompt.get_color(); 351 494 return true; 352 495 } … … 361 504 on_prompt_global_password(connection_settings& settings) 362 505 { 363 Gtk::HBox box; 364 Gtk::Label label(_("Session password:") ); 365 Gtk::Entry entry; 366 entry.set_visibility(false); 367 368 box.pack_start(label, Gtk::PACK_SHRINK); 369 box.pack_start(entry, Gtk::PACK_EXPAND_WIDGET); 370 box.set_spacing(10); 371 372 Prompt prompt( 373 *this, 374 obby::login::errstring( 375 obby::login::ERROR_WRONG_GLOBAL_PASSWORD 376 ), 377 _("Session password required. You have to type in the " 378 "password to be able to join the obby session."), 379 box, 380 Gtk::Stock::DIALOG_AUTHENTICATION 381 ); 382 383 // Do not allow OK if the entry is empty 384 prompt.set_response_sensitive(Gtk::RESPONSE_OK, false); 385 entry.signal_changed().connect( 386 sigc::compose( 387 sigc::bind<0>( 388 sigc::mem_fun( 389 prompt, 390 &DefaultDialog::set_response_sensitive 391 ), 392 Gtk::RESPONSE_OK 393 ), 394 sigc::compose( 395 sigc::ptr_fun(&logical_not), 396 sigc::compose( 397 &Glib::ustring::empty, 398 sigc::mem_fun( 399 entry, 400 &Gtk::Entry::get_text 401 ) 402 ) 403 ) 404 ) 405 ); 406 506 SessionPasswordPrompt prompt(*this); 407 507 if(prompt.run() == Gtk::RESPONSE_OK) 408 508 { 409 settings.global_password = entry.get_text();509 settings.global_password = prompt.get_password(); 410 510 return true; 411 511 } … … 420 520 on_prompt_user_password(connection_settings& settings) 421 521 { 422 Gtk::Table table; 423 Gtk::Label lbl_name(_("New name:"), Gtk::ALIGN_RIGHT); 424 Gtk::Label lbl_password(_("User password:"), Gtk::ALIGN_RIGHT); 425 Gtk::Entry ent_name; 426 Gtk::Entry ent_password; 427 ent_name.set_text(m_username); 428 ent_password.set_visibility(false); 429 430 table.attach(lbl_name, 0, 1, 0, 1, 431 Gtk::SHRINK, Gtk::SHRINK); 432 table.attach(lbl_password, 0, 1, 1, 2, 433 Gtk::SHRINK, Gtk::SHRINK); 434 table.attach(ent_name, 1, 2, 0, 1, 435 Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK); 436 table.attach(ent_password, 1, 2, 1, 2, 437 Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK); 438 table.set_spacings(5); 439 440 obby::format_string str( 441 _("User password for user '%0%' required. You may either " 442 "choose another user name, type in your user password or " 443 "cancel the connection.") 444 ); 445 446 str << m_username; 447 Prompt prompt( 448 *this, 449 obby::login::errstring(obby::login::ERROR_WRONG_USER_PASSWORD), 450 str.str(), 451 table, 452 Gtk::Stock::DIALOG_AUTHENTICATION 453 ); 454 455 prompt.set_response_sensitive(Gtk::RESPONSE_OK, false); 456 ent_password.grab_focus(); 457 458 sigc::slot<void> changed_slot( 459 sigc::compose( 460 sigc::bind<0>( 461 sigc::mem_fun( 462 prompt, 463 &DefaultDialog::set_response_sensitive 464 ), 465 Gtk::RESPONSE_OK 466 ), 467 sigc::compose( 468 sigc::ptr_fun(&logical_and), 469 sigc::compose( 470 sigc::ptr_fun(&logical_not), 471 sigc::compose( 472 &Glib::ustring::empty, 473 sigc::mem_fun( 474 ent_name, 475 &Gtk::Entry:: 476 get_text 477 ) 478 ) 479 ), 480 sigc::compose( 481 sigc::ptr_fun(&logical_or), 482 sigc::compose( 483 sigc::bind( 484 sigc::ptr_fun(static_cast< 485 compare_ustring_func 486 >(&Glib::operator!=) ), 487 sigc::ref(m_username) 488 ), 489 sigc::mem_fun( 490 ent_name, 491 &Gtk::Entry::get_text 492 ) 493 ), 494 sigc::compose( 495 sigc::ptr_fun(&logical_not), 496 sigc::compose( 497 &Glib::ustring::empty, 498 sigc::mem_fun( 499 ent_password, 500 &Gtk::Entry:: 501 get_text 502 ) 503 ) 504 ) 505 ) 506 ) 507 ) 508 ); 509 510 ent_name.signal_changed().connect(changed_slot); 511 ent_password.signal_changed().connect(changed_slot); 512 522 UserPasswordPrompt prompt(*this, m_username); 513 523 if(prompt.run() == Gtk::RESPONSE_OK) 514 524 { 515 m_username = ent_name.get_text();516 settings.name = ent_name.get_text();517 settings.user_password = ent_password.get_text();525 m_username = prompt.get_name(); 526 settings.name = prompt.get_name(); 527 settings.user_password = prompt.get_password(); 518 528 return true; 519 529 } -
src/passworddialog.cpp
r1662ea7 rdebf4ab 23 23 24 24 Gobby::PasswordDialog::PasswordDialog(Gtk::Window& parent, 25 const Glib::ustring& title, 26 bool request) 27 : DefaultDialog(title, parent, true, true), m_request(request), 28 m_table(3, 3), 29 m_icon(Gtk::Stock::DIALOG_AUTHENTICATION, Gtk::ICON_SIZE_DIALOG), 30 m_lbl_password("Password:", Gtk::ALIGN_RIGHT), 31 m_lbl_conf_password("Confirm password:", Gtk::ALIGN_RIGHT) 25 const Glib::ustring& title): 26 Gtk::Dialog(title, parent, true, true), m_table(3, 3), 27 m_icon(Gtk::Stock::DIALOG_AUTHENTICATION, Gtk::ICON_SIZE_DIALOG), 28 m_lbl_password("Password:", Gtk::ALIGN_RIGHT), 29 m_lbl_conf_password("Confirm password:", Gtk::ALIGN_RIGHT) 32 30 { 33 31 m_ent_password.set_visibility(false); 34 32 m_ent_conf_password.set_visibility(false); 35 33 m_info.set_line_wrap(true); 34 35 m_ent_password.set_activates_default(true); 36 m_ent_conf_password.set_activates_default(true); 36 37 37 38 m_table.set_spacings(5); … … 52 53 add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); 53 54 add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK); 55 set_default_response(Gtk::RESPONSE_OK); 54 56 55 57 show_all(); … … 58 60 m_info.hide(); 59 61 60 // Hide confirm password fields if a password is requested 61 if(request) 62 { 63 m_lbl_conf_password.hide(); 64 m_ent_conf_password.hide(); 65 } 66 else 67 { 68 m_ent_password.signal_changed().connect( 69 sigc::mem_fun( 70 *this, 71 &PasswordDialog::on_password_changed 72 ) 73 ); 62 m_ent_password.signal_changed().connect( 63 sigc::mem_fun(*this, &PasswordDialog::on_password_changed) 64 ); 74 65 75 m_ent_conf_password.signal_changed().connect( 76 sigc::mem_fun( 77 *this, 78 &PasswordDialog::on_password_changed 79 ) 80 ); 81 } 66 m_ent_conf_password.signal_changed().connect( 67 sigc::mem_fun(*this, &PasswordDialog::on_password_changed) 68 ); 82 69 83 70 set_response_sensitive(Gtk::RESPONSE_OK, false); … … 85 72 set_resizable(false); 86 73 set_border_width(10); 87 }88 89 Gobby::PasswordDialog::~PasswordDialog()90 {91 74 } 92 75 -
src/window.cpp
r84c0261 rdebf4ab 903 903 { 904 904 // Build password dialog with info 905 PasswordDialog dlg(*this, _("Set user password") , false);905 PasswordDialog dlg(*this, _("Set user password") ); 906 906 dlg.set_info(_( 907 907 "Set a user password for your user account. When you try to "
