1999-11-08 01:03:40 +00:00
|
|
|
/* goto_dlg.c
|
2003-11-28 19:02:41 +00:00
|
|
|
* Routines for "go to packet" window
|
1999-11-08 01:03:40 +00:00
|
|
|
*
|
2004-07-18 00:24:25 +00:00
|
|
|
* $Id$
|
1999-11-08 01:03:40 +00:00
|
|
|
*
|
2006-05-21 05:12:17 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
1999-11-08 01:03:40 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1999-11-08 01:03:40 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1999-11-08 01:03:40 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1999-11-08 01:03:40 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2002-01-21 07:37:49 +00:00
|
|
|
#include <epan/proto.h>
|
1999-11-08 01:03:40 +00:00
|
|
|
|
2008-04-13 01:54:20 +00:00
|
|
|
#include "../globals.h"
|
|
|
|
#include "../simple_dialog.h"
|
2009-07-25 09:45:35 +00:00
|
|
|
#include "../ui_util.h"
|
2008-04-13 01:54:20 +00:00
|
|
|
|
|
|
|
#include "gtk/goto_dlg.h"
|
|
|
|
#include "gtk/dlg_utils.h"
|
|
|
|
#include "gtk/gui_utils.h"
|
|
|
|
#include "gtk/help_dlg.h"
|
|
|
|
|
1999-11-08 01:03:40 +00:00
|
|
|
|
|
|
|
/* Capture callback data keys */
|
|
|
|
#define E_GOTO_FNUMBER_KEY "goto_fnumber_te"
|
|
|
|
|
|
|
|
static void
|
|
|
|
goto_frame_ok_cb(GtkWidget *ok_bt, gpointer parent_w);
|
|
|
|
|
|
|
|
void
|
2002-03-05 11:56:00 +00:00
|
|
|
goto_frame_cb(GtkWidget *w _U_, gpointer d _U_)
|
1999-11-08 01:03:40 +00:00
|
|
|
{
|
|
|
|
GtkWidget *goto_frame_w, *main_vb, *fnumber_hb, *fnumber_lb, *fnumber_te,
|
2005-01-20 23:17:23 +00:00
|
|
|
*bbox, *ok_bt, *cancel_bt, *help_bt;
|
1999-11-08 01:03:40 +00:00
|
|
|
|
2006-05-22 07:29:40 +00:00
|
|
|
goto_frame_w = dlg_window_new("Wireshark: Go To Packet");
|
2002-08-28 21:04:11 +00:00
|
|
|
|
1999-11-08 01:03:40 +00:00
|
|
|
/* Container for each row of widgets */
|
|
|
|
main_vb = gtk_vbox_new(FALSE, 3);
|
2008-06-29 15:51:43 +00:00
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(main_vb), 5);
|
1999-11-08 01:03:40 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(goto_frame_w), main_vb);
|
|
|
|
gtk_widget_show(main_vb);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
1999-11-08 01:03:40 +00:00
|
|
|
/* Frame number row */
|
|
|
|
fnumber_hb = gtk_hbox_new(FALSE, 3);
|
|
|
|
gtk_container_add(GTK_CONTAINER(main_vb), fnumber_hb);
|
|
|
|
gtk_widget_show(fnumber_hb);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2003-11-28 19:02:41 +00:00
|
|
|
fnumber_lb = gtk_label_new("Packet number:");
|
1999-11-08 01:03:40 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(fnumber_hb), fnumber_lb, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show(fnumber_lb);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
1999-11-08 01:03:40 +00:00
|
|
|
fnumber_te = gtk_entry_new();
|
|
|
|
gtk_box_pack_start(GTK_BOX(fnumber_hb), fnumber_te, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show(fnumber_te);
|
|
|
|
|
|
|
|
/* Button row: OK and cancel buttons */
|
2008-06-21 13:36:31 +00:00
|
|
|
bbox = dlg_button_row_new(GTK_STOCK_JUMP_TO, GTK_STOCK_CANCEL, GTK_STOCK_HELP, NULL);
|
1999-11-08 01:03:40 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(main_vb), bbox);
|
|
|
|
gtk_widget_show(bbox);
|
|
|
|
|
2008-04-11 16:44:31 +00:00
|
|
|
ok_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_JUMP_TO);
|
2008-04-11 23:16:06 +00:00
|
|
|
g_signal_connect(ok_bt, "clicked", G_CALLBACK(goto_frame_ok_cb), goto_frame_w);
|
1999-11-08 01:03:40 +00:00
|
|
|
|
2008-04-11 16:44:31 +00:00
|
|
|
cancel_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CANCEL);
|
2004-05-26 03:49:24 +00:00
|
|
|
window_set_cancel_button(goto_frame_w, cancel_bt, window_cancel_button_cb);
|
1999-11-08 01:03:40 +00:00
|
|
|
|
2008-06-21 13:36:31 +00:00
|
|
|
help_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_HELP);
|
|
|
|
g_signal_connect(help_bt, "clicked", G_CALLBACK(topic_cb), (gpointer)HELP_GOTO_DIALOG);
|
2005-01-20 23:17:23 +00:00
|
|
|
|
2004-05-26 03:49:24 +00:00
|
|
|
gtk_widget_grab_default(ok_bt);
|
1999-11-08 01:03:40 +00:00
|
|
|
|
2000-05-02 08:04:31 +00:00
|
|
|
/* Catch the "activate" signal on the frame number text entry, so that
|
|
|
|
if the user types Return there, we act as if the "OK" button
|
|
|
|
had been selected, as happens if Return is typed if some widget
|
|
|
|
that *doesn't* handle the Return key has the input focus. */
|
|
|
|
dlg_set_activate(fnumber_te, ok_bt);
|
|
|
|
|
2003-11-28 19:02:41 +00:00
|
|
|
/* Give the initial focus to the "Packet number" entry box. */
|
2000-03-15 08:54:24 +00:00
|
|
|
gtk_widget_grab_focus(fnumber_te);
|
|
|
|
|
2004-05-26 03:49:24 +00:00
|
|
|
/* Attach pointers to needed widgets to the capture prefs window/object */
|
2008-04-11 16:44:31 +00:00
|
|
|
g_object_set_data(G_OBJECT(goto_frame_w), E_GOTO_FNUMBER_KEY, fnumber_te);
|
2004-05-26 03:49:24 +00:00
|
|
|
|
2008-04-11 23:16:06 +00:00
|
|
|
g_signal_connect(goto_frame_w, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
|
2004-05-26 03:49:24 +00:00
|
|
|
|
1999-11-08 01:03:40 +00:00
|
|
|
gtk_widget_show(goto_frame_w);
|
2004-05-26 03:49:24 +00:00
|
|
|
window_present(goto_frame_w);
|
1999-11-08 01:03:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-03-05 11:56:00 +00:00
|
|
|
goto_frame_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w)
|
1999-11-08 01:03:40 +00:00
|
|
|
{
|
2002-11-03 17:38:45 +00:00
|
|
|
GtkWidget *fnumber_te;
|
|
|
|
const gchar *fnumber_text;
|
|
|
|
guint fnumber;
|
|
|
|
char *p;
|
1999-11-08 01:03:40 +00:00
|
|
|
|
2008-04-11 16:44:31 +00:00
|
|
|
fnumber_te = (GtkWidget *)g_object_get_data(G_OBJECT(parent_w), E_GOTO_FNUMBER_KEY);
|
1999-11-08 01:03:40 +00:00
|
|
|
|
|
|
|
fnumber_text = gtk_entry_get_text(GTK_ENTRY(fnumber_te));
|
|
|
|
fnumber = strtoul(fnumber_text, &p, 10);
|
|
|
|
if (p == fnumber_text || *p != '\0') {
|
|
|
|
/* Illegal number.
|
|
|
|
XXX - what about negative numbers (which "strtoul()" allows)?
|
|
|
|
Can we hack up signal handlers for the widget to make it
|
|
|
|
reject attempts to type in characters other than digits? */
|
2004-01-31 03:22:42 +00:00
|
|
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
2003-11-28 19:02:41 +00:00
|
|
|
"The packet number you entered isn't a valid number.");
|
1999-11-08 01:03:40 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-02-04 18:44:44 +00:00
|
|
|
if (cf_goto_frame(&cfile, fnumber)) {
|
2003-03-02 22:07:25 +00:00
|
|
|
/* We succeeded in going to that frame; we're done. */
|
2004-05-26 03:49:24 +00:00
|
|
|
window_destroy(GTK_WIDGET(parent_w));
|
1999-11-30 07:27:37 +00:00
|
|
|
}
|
1999-11-08 01:03:40 +00:00
|
|
|
}
|
|
|
|
|
2004-06-01 17:33:37 +00:00
|
|
|
/*
|
|
|
|
* Go to frame specified by currently selected protocol tree item.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
goto_framenum_cb(GtkWidget *w _U_, gpointer data _U_)
|
|
|
|
{
|
2005-02-04 18:44:44 +00:00
|
|
|
cf_goto_framenum(&cfile);
|
2004-06-01 17:33:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
goto_top_frame_cb(GtkWidget *w _U_, gpointer d _U_)
|
|
|
|
{
|
2011-03-08 01:52:25 +00:00
|
|
|
cf_goto_top_frame();
|
2004-06-01 17:33:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
goto_bottom_frame_cb(GtkWidget *w _U_, gpointer d _U_)
|
|
|
|
{
|
2011-03-08 01:52:25 +00:00
|
|
|
cf_goto_bottom_frame();
|
2004-06-01 17:33:37 +00:00
|
|
|
}
|
|
|
|
|
2009-07-25 09:45:35 +00:00
|
|
|
void
|
|
|
|
goto_next_frame_cb(GtkWidget *w _U_, gpointer d _U_)
|
|
|
|
{
|
|
|
|
new_packet_list_next();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
goto_previous_frame_cb(GtkWidget *w _U_, gpointer d _U_)
|
|
|
|
{
|
|
|
|
new_packet_list_prev();
|
|
|
|
}
|
2004-06-01 17:33:37 +00:00
|
|
|
|