void CapturePreferencesFrame::updateWidgets() { #ifdef HAVE_LIBPCAP GList *if_list, *combo_list, *combo_entry; int err; ui->defaultInterfaceComboBox->clear(); if_list = capture_interface_list(&err, NULL,main_window_update); combo_list = build_capture_combo_list(if_list, FALSE); free_interface_list(if_list); for (combo_entry = combo_list; combo_entry != NULL && combo_entry->data != NULL; combo_entry = g_list_next(combo_entry)) { ui->defaultInterfaceComboBox->addItem(QString((const char *)combo_entry->data)); } if (pref_device_->stashed_val.string) { ui->defaultInterfaceComboBox->setEditText(pref_device_->stashed_val.string); } else { ui->defaultInterfaceComboBox->clearEditText(); } ui->capturePromModeCheckBox->setChecked(pref_prom_mode_->stashed_val.boolval); ui->capturePcapNgCheckBox->setChecked(pref_pcap_ng_->stashed_val.boolval); ui->captureRealTimeCheckBox->setChecked(pref_real_time_->stashed_val.boolval); ui->captureAutoScrollCheckBox->setChecked(pref_auto_scroll_->stashed_val.boolval); ui->captureShowInfoCheckBox->setChecked(pref_show_info_->stashed_val.boolval); #endif // HAVE_LIBPCAP }
GtkWidget* capture_prefs_show(void) { GtkWidget *main_tb, *main_vb; GtkWidget *if_cbxe, *if_lb, *promisc_cb, *pcap_ng_cb, *sync_cb, *auto_scroll_cb, *show_info_cb; GtkWidget *ifopts_lb, *ifopts_bt; GList *if_list, *combo_list; int err; int row = 0; const gchar *tooltips_text; /* Main vertical box */ main_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 7, FALSE); gtk_container_set_border_width(GTK_CONTAINER(main_vb), 5); /* Main table */ main_tb = gtk_table_new(CAPTURE_TABLE_ROWS, 2, FALSE); gtk_box_pack_start(GTK_BOX(main_vb), main_tb, FALSE, FALSE, 0); gtk_table_set_row_spacings(GTK_TABLE(main_tb), 10); gtk_table_set_col_spacings(GTK_TABLE(main_tb), 15); gtk_widget_show(main_tb); /* Default device */ if_lb = gtk_label_new("Default interface:"); gtk_table_attach_defaults(GTK_TABLE(main_tb), if_lb, 0, 1, row, row+1); gtk_misc_set_alignment(GTK_MISC(if_lb), 1.0f, 0.5f); gtk_widget_show(if_lb); if_cbxe = gtk_combo_box_text_new_with_entry(); /* * XXX - what if we can't get the list? */ if_list = capture_interface_list(&err, NULL); combo_list = build_capture_combo_list(if_list, FALSE); free_interface_list(if_list); if (combo_list != NULL) { GList *combo_entry; for (combo_entry = combo_list; combo_entry != NULL; combo_entry = g_list_next(combo_entry)) { gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(if_cbxe), combo_entry->data); } } if (prefs.capture_device) { gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(if_cbxe))), prefs.capture_device); } else if (combo_list != NULL) { gtk_combo_box_set_active(GTK_COMBO_BOX(if_cbxe), 0); } free_capture_combo_list(combo_list); gtk_table_attach_defaults(GTK_TABLE(main_tb), if_cbxe, 1, 2, row, row+1); tooltips_text = "The default interface to be captured from."; gtk_widget_set_tooltip_text(if_lb, tooltips_text); gtk_widget_set_tooltip_text(gtk_bin_get_child(GTK_BIN(if_cbxe)), tooltips_text); gtk_widget_show(if_cbxe); g_object_set_data(G_OBJECT(main_vb), DEVICE_KEY, if_cbxe); row++; /* Interface properties */ ifopts_lb = gtk_label_new("Interfaces:"); gtk_table_attach_defaults(GTK_TABLE(main_tb), ifopts_lb, 0, 1, row, row+1); gtk_misc_set_alignment(GTK_MISC(ifopts_lb), 1.0f, 0.5f); gtk_widget_show(ifopts_lb); ifopts_bt = gtk_button_new_from_stock(WIRESHARK_STOCK_EDIT); tooltips_text = "Open a dialog box to set various interface options."; gtk_widget_set_tooltip_text(ifopts_lb, tooltips_text); gtk_widget_set_tooltip_text(ifopts_bt, tooltips_text); g_signal_connect(ifopts_bt, "clicked", G_CALLBACK(ifopts_edit_cb), NULL); gtk_table_attach_defaults(GTK_TABLE(main_tb), ifopts_bt, 1, 2, row, row+1); row++; /* Promiscuous mode */ promisc_cb = create_preference_check_button(main_tb, row++, "Capture packets in promiscuous mode:", "Usually a network card will only capture the traffic sent to its own network address. " "If you want to capture all traffic that the network card can \"see\", mark this option. " "See the FAQ for some more details of capturing packets from a switched network. ", prefs.capture_prom_mode); g_object_set_data(G_OBJECT(main_vb), PROM_MODE_KEY, promisc_cb); /* Pcap-NG format */ pcap_ng_cb = create_preference_check_button(main_tb, row++, "Capture packets in pcap-ng format:", "Capture packets in the next-generation capture file format.", prefs.capture_pcap_ng); g_object_set_data(G_OBJECT(main_vb), PCAP_NG_KEY, pcap_ng_cb); /* Real-time capture */ sync_cb = create_preference_check_button(main_tb, row++, "Update list of packets in real time:", "Update the list of packets while capture is in progress. " "Don't use this option if you notice packet drops.", prefs.capture_real_time); g_object_set_data(G_OBJECT(main_vb), CAPTURE_REAL_TIME_KEY, sync_cb); /* Auto-scroll real-time capture */ auto_scroll_cb = create_preference_check_button(main_tb, row++, "Automatic scrolling in live capture:", "Automatic scrolling of the packet list while live capture is in progress. ", prefs.capture_auto_scroll); g_object_set_data(G_OBJECT(main_vb), AUTO_SCROLL_KEY, auto_scroll_cb); /* Show capture info dialog */ show_info_cb = create_preference_check_button(main_tb, row++, "Hide capture info dialog:", "Hide the capture info dialog while capturing. ", !prefs.capture_show_info); g_object_set_data(G_OBJECT(main_vb), SHOW_INFO_KEY, show_info_cb); /* Show 'em what we got */ gtk_widget_show_all(main_vb); return(main_vb); }