728
763
return FRS_PRINT_ERROR;
766
#if GTK_MAJOR_VERSION >= 2
768
follow_find_cb(GtkWidget * w _U_, gpointer data)
770
follow_info_t *follow_info = data;
771
GtkTooltips *tooltips;
772
GtkWidget *find_dlg_w, *main_vb, *buttons_row, *find_lb;
773
GtkWidget *find_hb, *find_text_box, *find_bt, *cancel_bt;
775
tooltips = gtk_tooltips_new();
777
if (follow_info->find_dlg_w != NULL) {
778
/* There's already a dialog box; reactivate it. */
779
reactivate_window(follow_info->find_dlg_w);
783
/* Create the find box */
784
find_dlg_w = dlg_window_new("Wireshark: Find text");
785
gtk_window_set_transient_for(GTK_WINDOW(find_dlg_w),
786
GTK_WINDOW(follow_info->streamwindow));
787
gtk_window_set_destroy_with_parent(GTK_WINDOW(find_dlg_w), TRUE);
788
follow_info->find_dlg_w = find_dlg_w;
790
SIGNAL_CONNECT(find_dlg_w, "destroy", follow_find_destroy_cb, follow_info);
791
SIGNAL_CONNECT(find_dlg_w, "delete_event", window_delete_event_cb, NULL);
793
/* Main vertical box */
794
main_vb = gtk_vbox_new(FALSE, 3);
795
gtk_container_border_width(GTK_CONTAINER(main_vb), 5);
796
gtk_container_add(GTK_CONTAINER(find_dlg_w), main_vb);
798
/* Horizontal box for find label, entry field and up/down radio buttons*/
799
find_hb = gtk_hbox_new(FALSE, 3);
800
gtk_container_add(GTK_CONTAINER(main_vb), find_hb);
801
gtk_widget_show(find_hb);
804
find_lb = gtk_label_new("Find text:");
805
gtk_box_pack_start(GTK_BOX(find_hb), find_lb, FALSE, FALSE, 0);
806
gtk_widget_show(find_lb);
809
find_text_box = gtk_entry_new();
810
gtk_box_pack_start(GTK_BOX(find_hb), find_text_box, FALSE, FALSE, 0);
811
gtk_tooltips_set_tip(tooltips, find_text_box, "Text to search for (case sensitive)", NULL);
812
gtk_widget_show(find_text_box);
815
buttons_row = dlg_button_row_new(GTK_STOCK_FIND, GTK_STOCK_CANCEL, NULL);
816
gtk_container_add(GTK_CONTAINER(main_vb), buttons_row);
817
find_bt = OBJECT_GET_DATA(buttons_row, GTK_STOCK_FIND);
818
cancel_bt = OBJECT_GET_DATA(buttons_row, GTK_STOCK_CANCEL);
820
SIGNAL_CONNECT(find_bt, "clicked", follow_find_button_cb, follow_info);
821
OBJECT_SET_DATA(find_bt, "find_string", find_text_box);
822
window_set_cancel_button(find_dlg_w, cancel_bt, window_cancel_button_cb);
824
/* Hitting return in the find field "clicks" the find button */
825
dlg_set_activate(find_text_box, find_bt);
827
/* Show the dialog */
828
gtk_widget_show_all(find_dlg_w);
829
window_present(find_dlg_w);
833
follow_find_button_cb(GtkWidget * w, gpointer data)
836
const gchar *find_string;
837
follow_info_t *follow_info = data;
838
GtkTextBuffer *buffer;
839
GtkTextIter iter, match_start, match_end;
840
GtkTextMark *last_pos_mark;
841
GtkWidget *find_string_w;
843
/* Get the text the user typed into the find field */
844
find_string_w = (GtkWidget *)OBJECT_GET_DATA(w, "find_string");
845
find_string = gtk_entry_get_text(GTK_ENTRY(find_string_w));
847
/* Get the buffer associated with the follow stream */
848
buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(follow_info->text));
849
gtk_text_buffer_get_start_iter(buffer, &iter);
851
/* Look for the search string in the buffer */
852
last_pos_mark = gtk_text_buffer_get_mark(buffer, "last_position");
854
gtk_text_buffer_get_iter_at_mark(buffer, &iter, last_pos_mark);
856
found = gtk_text_iter_forward_search(&iter, find_string, 0, &match_start,
861
gtk_text_buffer_select_range(buffer, &match_start, &match_end);
862
last_pos_mark = gtk_text_buffer_create_mark (buffer, "last_position",
864
gtk_text_view_scroll_mark_onscreen(GTK_TEXT_VIEW(follow_info->text), last_pos_mark);
866
/* We didn't find a match */
867
simple_dialog(ESD_TYPE_INFO, ESD_BTN_OK,
868
"%sFind text has reached the end of the followed "
869
"stream%s\n\nThe next search will start from the "
870
"beginning", simple_dialog_primary_start(),
871
simple_dialog_primary_end());
873
gtk_text_buffer_delete_mark(buffer, last_pos_mark);
879
follow_find_destroy_cb(GtkWidget * win _U_, gpointer data)
881
follow_info_t *follow_info = data;
883
/* Note that we no longer have a dialog box. */
884
follow_info->find_dlg_w = NULL;
886
#endif /* GTK_MAJOR_VERSION >= 2 */
732
890
* XXX - for text printing, we probably want to wrap lines at 80 characters;
733
891
* (PostScript printing is doing this already), and perhaps put some kind of