[gtkmm] How to update text in a TextView?



Hi!

I create a TextView, set the text in the buffer
and later I want to update the displayed text
in the still opened window.

I´ve tried it with set_text/set_buffer, but it doesn´t change
the text!


m_textViewWindowExists = false;

TextViewWindow tvw("Constraint Typ Beschreibung", m_description);
if (!m_textViewWindowExists) {
  m_textViewWindowExists = true;
  Gtk::Main::run(tvw);
}
else {
  tvw.updateText(m_description);
}



TextViewWindow::TextViewWindow(						
  const string& title,
  const string& message)
  :
  m_title(title),
  m_message(message),
  m_CloseButton("Close")
{
  cout << "START TextViewWindow::TextViewWindow()" << endl;

  set_border_width(1);
  set_default_size(300, 200);
  set_title(m_title);

  m_textView.set_wrap_mode(Gtk::WRAP_WORD);

  m_TextBuffer = Gtk::TextBuffer::create();
  m_TextBuffer->set_text(m_message);
  m_textView.set_buffer(m_TextBuffer);

  Gtk::VBox *VBox = Gtk::manage(new Gtk::VBox());
  VBox->pack_start(m_textView);
  VBox->pack_start(m_CloseButton, Gtk::PACK_SHRINK);
  m_CloseButton.signal_clicked().connect(slot(*this, &TextViewWindow::onCloseClicked));

  add(*VBox); // this object

  show_all_children();

  cout << "END   TextViewWindow::TextViewWindow()" << endl;
}


void TextViewWindow::updateText(const string& message)
{
  cout << "START TextViewWindow::updateText()" << endl;

  m_message = message;
  cout << "      " << m_message << endl;

  m_TextBuffer->set_text(m_message);
  m_textView.set_buffer(m_TextBuffer);

  cout << "END  TextViewWindow::updateText()" << endl;
}





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