diff options
author | Guy Harris <guy@alum.mit.edu> | 2003-03-02 22:07:25 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2003-03-02 22:07:25 +0000 |
commit | 6c9deead35287fda4d7d8297aab2cc1ce9a53b93 (patch) | |
tree | 66c278c6ea06c491919bdb367830815f56b2b48e | |
parent | 3b37905e24b6a081e3538fc387a3febe7098fa67 (diff) |
Have "goto_frame()" put up error dialog boxes itself, rather than having
its callers put up the same error dialog boxes. Have it just return a
success vs. failure Boolean.
svn path=/trunk/; revision=7254
-rw-r--r-- | file.c | 23 | ||||
-rw-r--r-- | file.h | 9 | ||||
-rw-r--r-- | gtk/goto_dlg.c | 17 | ||||
-rw-r--r-- | gtk/main.c | 22 |
4 files changed, 24 insertions, 47 deletions
@@ -1,7 +1,7 @@ /* file.c * File I/O routines * - * $Id: file.c,v 1.296 2002/12/01 20:19:44 guy Exp $ + * $Id: file.c,v 1.297 2003/03/02 22:07:21 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -1554,7 +1554,7 @@ find_packet(capture_file *cf, dfilter_t *sfcode) return FALSE; /* failure */ } -goto_result_t +gboolean goto_frame(capture_file *cf, guint fnumber) { frame_data *fdata; @@ -1563,10 +1563,19 @@ goto_frame(capture_file *cf, guint fnumber) for (fdata = cf->plist; fdata != NULL && fdata->num < fnumber; fdata = fdata->next) ; - if (fdata == NULL) - return NO_SUCH_FRAME; /* we didn't find that frame */ - if (!fdata->flags.passed_dfilter) - return FRAME_NOT_DISPLAYED; /* the frame with that number isn't displayed */ + if (fdata == NULL) { + /* we didn't find that frame */ + simple_dialog(ESD_TYPE_CRIT, NULL, + "There is no frame with that frame number."); + return FALSE; /* we failed to go to that frame */ + } + if (!fdata->flags.passed_dfilter) { + /* the frame with that number isn't displayed */ + /* XXX - add it to the set of displayed frames? */ + simple_dialog(ESD_TYPE_CRIT, NULL, + "The frame with that frame number is not currently being displayed."); + return FALSE; /* we failed to go to that frame */ + } /* We found that frame, and it's currently being displayed. Find what row it's in. */ @@ -1575,7 +1584,7 @@ goto_frame(capture_file *cf, guint fnumber) /* Select that row, make it the focus row, and make it visible. */ packet_list_set_selected_row(row); - return FOUND_FRAME; + return TRUE; /* we got to that frame */ } /* Select the packet on a given row. */ @@ -1,7 +1,7 @@ /* file.h * Definitions for file structures and routines * - * $Id: file.h,v 1.98 2002/09/06 22:45:40 sahlberg Exp $ + * $Id: file.h,v 1.99 2003/03/02 22:07:21 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -57,12 +57,7 @@ int print_packets(capture_file *cf, print_args_t *print_args); void change_time_formats(capture_file *); gboolean find_packet(capture_file *cf, dfilter_t *sfcode); -typedef enum { - FOUND_FRAME, /* found the frame */ - NO_SUCH_FRAME, /* no frame with that number */ - FRAME_NOT_DISPLAYED /* frame with that number isn't displayed */ -} goto_result_t; -goto_result_t goto_frame(capture_file *cf, guint fnumber); +gboolean goto_frame(capture_file *cf, guint fnumber); void select_packet(capture_file *, int); void unselect_packet(capture_file *); diff --git a/gtk/goto_dlg.c b/gtk/goto_dlg.c index a07b00ab1e..2d8e64b508 100644 --- a/gtk/goto_dlg.c +++ b/gtk/goto_dlg.c @@ -1,7 +1,7 @@ /* goto_dlg.c * Routines for "go to frame" window * - * $Id: goto_dlg.c,v 1.19 2002/11/11 15:39:05 oabad Exp $ + * $Id: goto_dlg.c,v 1.20 2003/03/02 22:07:25 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -143,20 +143,9 @@ goto_frame_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w) return; } - switch (goto_frame(&cfile, fnumber)) { - - case NO_SUCH_FRAME: - simple_dialog(ESD_TYPE_CRIT, NULL, "There is no frame with that frame number."); - return; - - case FRAME_NOT_DISPLAYED: - /* XXX - add it to the display filter? */ - simple_dialog(ESD_TYPE_CRIT, NULL, "The frame with that frame number is not currently being displayed."); - return; - - case FOUND_FRAME: + if (goto_frame(&cfile, fnumber)) { + /* We succeeded in going to that frame; we're done. */ gtk_widget_destroy(GTK_WIDGET(parent_w)); - break; } } diff --git a/gtk/main.c b/gtk/main.c index fa594a5bd0..2230e97316 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -1,6 +1,6 @@ /* main.c * - * $Id: main.c,v 1.282 2003/03/01 10:18:54 guy Exp $ + * $Id: main.c,v 1.283 2003/03/02 22:07:25 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -231,24 +231,8 @@ goto_framenum_cb(GtkWidget *w _U_, gpointer data _U_) g_assert(hfinfo); if (hfinfo->type == FT_FRAMENUM) { framenum = fvalue_get_integer(finfo_selected->value); - if (framenum != 0) { - switch (goto_frame(&cfile, framenum)) { - - case NO_SUCH_FRAME: - simple_dialog(ESD_TYPE_CRIT, NULL, - "There is no frame with that frame number."); - break; - - case FRAME_NOT_DISPLAYED: - /* XXX - add it to the display filter? */ - simple_dialog(ESD_TYPE_CRIT, NULL, - "The frame with that frame number is not currently being displayed."); - return; - - case FOUND_FRAME: - break; - } - } + if (framenum != 0) + goto_frame(&cfile, framenum); } } } |