[gtkmm] Signal propagation



Hello,

In a class I have derived from Gtk::Dialog, I'd like to verify the
dialog's user input is valid, and require re-entry if it's invalid.

I've done this, overriding Gtk::Dialog::on_response():

void
staff_details::on_response(int response_id)
{
  if (response_id == Gtk::RESPONSE_OK) // Modify the user
    {
      Gtk::TreeModel::Children rows = m_parent->list_store->children();
      Gtk::TreeModel::Children::const_iterator cur;
      for (cur = rows.begin(); cur != rows.end(); cur++)
        {
          Gtk::TreeModel::Row row = *cur;
          Glib::ustring cur_nick = row[m_parent->list_columns.m_col_nick];
 
          // Is the nickname already in use?
          if (cur_nick.compare(m_nick_entry.get_text()) == 0)
            {
              Gtk::MessageDialog dialog (*this,
                                         "The nickname is already being used by another user.  "
                                         "Please choose a different nickname.",
                                         Gtk::MESSAGE_ERROR,
                                         Gtk::BUTTONS_OK,
                                         true);
              dialog.run();
 
              m_nick_entry.grab_focus();
              // signal_response().emission_stop();
              return;
            }
        }
    }
  //  Gtk::Dialog::on_response();
}

However, run() always returns, whether or not I call the subclassed
on_response, and segfaults if I call signal_response().emission_stop.
How should I prevent the "response" signal from closing the dialog?


Thanks,
Roger

-- 
Roger Leigh

                Printing on GNU/Linux?  http://gimp-print.sourceforge.net/
                GPG Public Key: 0x25BFB848.  Please sign and encrypt your mail.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]