Changeset 1662ea7cb97e74c04650ddda1130c2ea7a4d07ce

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

[project @ Disable OK button in password dialog when passwords do not match]

Original author: Armin Burgmeier <armin@…>
Date: 2006-03-07 18:03:45+00:00

Files:
2 modified

Legend:

Unmodified
Added
Removed
  • inc/passworddialog.hpp

    r91dd7f0 r1662ea7  
    3939        Glib::ustring get_password() const; 
    4040protected: 
    41         virtual void on_response(int response_id); 
     41        void on_password_changed(); 
    4242 
    4343        bool m_request; 
  • src/passworddialog.cpp

    r91dd7f0 r1662ea7  
    6464                m_ent_conf_password.hide(); 
    6565        } 
     66        else 
     67        { 
     68                m_ent_password.signal_changed().connect( 
     69                        sigc::mem_fun( 
     70                                *this, 
     71                                &PasswordDialog::on_password_changed 
     72                        ) 
     73                ); 
     74 
     75                m_ent_conf_password.signal_changed().connect( 
     76                        sigc::mem_fun( 
     77                                *this, 
     78                                &PasswordDialog::on_password_changed 
     79                        ) 
     80                ); 
     81        } 
     82 
     83        set_response_sensitive(Gtk::RESPONSE_OK, false); 
    6684         
    6785        set_resizable(false); 
     
    89107} 
    90108 
    91 void Gobby::PasswordDialog::on_response(int response_id) 
     109void Gobby::PasswordDialog::on_password_changed() 
    92110{ 
    93         if(response_id == Gtk::RESPONSE_OK && !m_request) 
    94         { 
    95                 if(m_ent_conf_password.get_text() != m_ent_password.get_text() ) 
    96                 { 
    97                         Gtk::MessageDialog dlg( 
    98                                 *this, 
    99                                 _("Passwords do not match"), 
    100                                 false, 
    101                                 Gtk::MESSAGE_ERROR, 
    102                                 Gtk::BUTTONS_OK, 
    103                                 true 
    104                         ); 
    105  
    106                         dlg.run(); 
    107                         return; 
    108                 } 
    109         } 
    110  
    111         Gtk::Dialog::on_response(response_id); 
     111        if(m_ent_password.get_text().empty() ) 
     112                set_response_sensitive(Gtk::RESPONSE_OK, false); 
     113        else if(m_ent_password.get_text() != m_ent_conf_password.get_text() ) 
     114                set_response_sensitive(Gtk::RESPONSE_OK, false); 
     115        else 
     116                set_response_sensitive(Gtk::RESPONSE_OK, true); 
    112117} 
    113