예제 #1
0
void
NetLogGuiGtkWindow::on_clear_clicked()
{
  int page = ntb_logviewers.get_current_page();
  if (page >= 0) {
    Gtk::ScrolledWindow *scrolled = dynamic_cast<Gtk::ScrolledWindow *>(ntb_logviewers.get_nth_page(page));
    LogView *lv = dynamic_cast<LogView *>(scrolled->get_child());
    lv->clear();
  }
}
예제 #2
0
/** Event handler for connection button. */
void
NetLogGuiGtkWindow::on_connection_clicked()
{
  ServiceChooserDialog ssd(*this);
  if (ssd.run() ) {
    struct sockaddr_in saddr;
    socklen_t saddr_size = sizeof(struct sockaddr_in);
    Glib::ustring name, hostname, ipaddr;
    unsigned short int port = 1910;
    std::list<std::string> txt;
    int page = -1;

    try {
      ssd.get_selected_service (name, hostname, ipaddr, port);
      ssd.get_raw_address((struct sockaddr *)&saddr, saddr_size);
      NetworkService *service = new NetworkService(name.c_str(), "_fawkes._tcp", "",
						   hostname.c_str(), port,
						   (struct sockaddr *)&saddr,
						   saddr_size, txt);
      page = on_service_added(service);
      delete service;

      if ( page >= 0 ) {
	Gtk::ScrolledWindow *scrolled = dynamic_cast<Gtk::ScrolledWindow *>(ntb_logviewers.get_nth_page(page));
	LogView *logview = dynamic_cast<LogView *>(scrolled->get_child());
	logview->get_client()->connect(ipaddr.c_str(), port);
      }
    } catch (Exception &e) {
      Glib::ustring message = *(e.begin());
      Gtk::MessageDialog md(*this, message, /* markup */ false,
			    Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK,
			    /* modal */ true);
      md.set_title("Connection failed");
      md.run();

      ntb_logviewers.remove_page(page);
    }
  }
}