void GscHelpWindow::set_topic(const Glib::ustring& topic)
{
	this->selection_callback_enabled = false;  // temporarily disable it

	// scroll to it

	Gtk::TextView* content = this->lookup_widget<Gtk::TextView*>("content_textview");
	if (content) {
		Glib::RefPtr<Gtk::TextBuffer> buffer = content->get_buffer();

		Glib::RefPtr<Gtk::TextMark> mark = buffer->get_mark(topic);
		if (mark)
			content->scroll_to(mark, 0., 0., 0.);
	}

	// select it in tree view
	Gtk::TreeView* treeview = this->lookup_widget<Gtk::TreeView*>("topics_treeview");

	if (treeview && !list_store->children().empty()) {
		for (Gtk::TreeIter iter = list_store->children().begin(); iter != list_store->children().end(); ++iter) {
			if (iter->get_value(col_topic) == topic) {
				selection->select(*iter);
				treeview->scroll_to_cell(list_store->get_path(iter), *(treeview->get_column(0)), 0.3, 0.);  // about 30% from top
				break;
			}
		}
	}

	this->selection_callback_enabled = true;  // enable it back
}
Exemplo n.º 2
0
void TextBoxImpl::append_text(::mforms::TextBox *self, const std::string &text, bool scroll_to_end)
{
  TextBoxImpl* cb = self->get_data<TextBoxImpl>();

  if ( cb )
  {
    Gtk::TextView *tv = cb->_text;
    if (tv)
    {
      Glib::RefPtr<Gtk::TextBuffer> buf = tv->get_buffer();
      buf->insert(buf->end(), text);

      if (scroll_to_end)
      {
        Gtk::TextIter it = buf->end();
        tv->scroll_to(it, 0.3);
      }
    }
  }
}
Exemplo n.º 3
0
void MainWindow::add_output(const std::string& contents) {
    m_text_buf->set_text(m_text_buf->get_text() + contents);
    auto end = m_text_buf->get_iter_at_line(m_text_buf->get_line_count() + 100);
    m_textview.scroll_to(end);
}