forked from osmocom/wireshark
8ed7a73e22
Cast away some implicit 64-bit-to-32-bit conversion errors due to use of sizeof. Cast away some implicit 64-bit-to-32-bit conversion errors due to use of strtol() and strtoul(). Change some data types to avoid those implicit conversion warnings. When assigning a constant to a float, make sure the constant isn't a double, by appending "f" to the constant. Constify a bunch of variables, parameters, and return values to eliminate warnings due to strings being given const qualifiers. Cast away those warnings in some cases where an API we don't control forces us to do so. Enable a bunch of additional warnings by default. Note why at least some of the other warnings aren't enabled. randpkt.c and text2pcap.c are used to build programs, so they don't need to be in EXTRA_DIST. If the user specifies --enable-warnings-as-errors, add -Werror *even if the user specified --enable-extra-gcc-flags; assume they know what they're doing and are willing to have the compile fail due to the extra GCC warnings being treated as errors. svn path=/trunk/; revision=46748
172 lines
5.1 KiB
C
172 lines
5.1 KiB
C
/* goto_dlg.c
|
|
* Routines for "go to packet" window
|
|
*
|
|
* $Id$
|
|
*
|
|
* Wireshark - Network traffic analyzer
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
* Copyright 1998 Gerald Combs
|
|
*
|
|
* 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.
|
|
*
|
|
* 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.
|
|
*
|
|
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
*/
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include <epan/proto.h>
|
|
|
|
#include "../globals.h"
|
|
#include "ui/simple_dialog.h"
|
|
#include "ui/ui_util.h"
|
|
|
|
#include "ui/gtk/goto_dlg.h"
|
|
#include "ui/gtk/dlg_utils.h"
|
|
#include "ui/gtk/gui_utils.h"
|
|
#include "ui/gtk/help_dlg.h"
|
|
|
|
|
|
/* 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
|
|
goto_frame_cb(GtkWidget *w _U_, gpointer d _U_)
|
|
{
|
|
GtkWidget *goto_frame_w, *main_vb, *fnumber_hb, *fnumber_lb, *fnumber_te,
|
|
*bbox, *ok_bt, *cancel_bt, *help_bt;
|
|
|
|
goto_frame_w = dlg_window_new("Wireshark: Go To Packet");
|
|
|
|
/* Container for each row of widgets */
|
|
main_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE);
|
|
gtk_container_set_border_width(GTK_CONTAINER(main_vb), 5);
|
|
gtk_container_add(GTK_CONTAINER(goto_frame_w), main_vb);
|
|
gtk_widget_show(main_vb);
|
|
|
|
/* Frame number row */
|
|
fnumber_hb = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3, FALSE);
|
|
gtk_box_pack_start(GTK_BOX (main_vb), fnumber_hb, TRUE, TRUE, 0);
|
|
gtk_widget_show(fnumber_hb);
|
|
|
|
fnumber_lb = gtk_label_new("Packet number:");
|
|
gtk_box_pack_start(GTK_BOX(fnumber_hb), fnumber_lb, FALSE, FALSE, 0);
|
|
gtk_widget_show(fnumber_lb);
|
|
|
|
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 */
|
|
bbox = dlg_button_row_new(GTK_STOCK_JUMP_TO, GTK_STOCK_CANCEL, GTK_STOCK_HELP, NULL);
|
|
gtk_box_pack_start(GTK_BOX (main_vb), bbox, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show(bbox);
|
|
|
|
ok_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_JUMP_TO);
|
|
g_signal_connect(ok_bt, "clicked", G_CALLBACK(goto_frame_ok_cb), goto_frame_w);
|
|
|
|
cancel_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CANCEL);
|
|
window_set_cancel_button(goto_frame_w, cancel_bt, window_cancel_button_cb);
|
|
|
|
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);
|
|
|
|
gtk_widget_grab_default(ok_bt);
|
|
|
|
/* 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);
|
|
|
|
/* Give the initial focus to the "Packet number" entry box. */
|
|
gtk_widget_grab_focus(fnumber_te);
|
|
|
|
/* Attach pointers to needed widgets to the capture prefs window/object */
|
|
g_object_set_data(G_OBJECT(goto_frame_w), E_GOTO_FNUMBER_KEY, fnumber_te);
|
|
|
|
g_signal_connect(goto_frame_w, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
|
|
|
|
gtk_widget_show(goto_frame_w);
|
|
window_present(goto_frame_w);
|
|
}
|
|
|
|
static void
|
|
goto_frame_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w)
|
|
{
|
|
GtkWidget *fnumber_te;
|
|
const gchar *fnumber_text;
|
|
guint fnumber;
|
|
char *p;
|
|
|
|
fnumber_te = (GtkWidget *)g_object_get_data(G_OBJECT(parent_w), E_GOTO_FNUMBER_KEY);
|
|
|
|
fnumber_text = gtk_entry_get_text(GTK_ENTRY(fnumber_te));
|
|
fnumber = (guint) 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?
|
|
What about numbers > the maximum possible guint? */
|
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
|
"The packet number you entered isn't a valid number.");
|
|
return;
|
|
}
|
|
|
|
if (cf_goto_frame(&cfile, fnumber)) {
|
|
/* We succeeded in going to that frame; we're done. */
|
|
window_destroy(GTK_WIDGET(parent_w));
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Go to frame specified by currently selected protocol tree item.
|
|
*/
|
|
void
|
|
goto_framenum_cb(GtkWidget *w _U_, gpointer data _U_)
|
|
{
|
|
cf_goto_framenum(&cfile);
|
|
}
|
|
|
|
void
|
|
goto_top_frame_cb(GtkWidget *w _U_, gpointer d _U_)
|
|
{
|
|
cf_goto_top_frame();
|
|
}
|
|
|
|
void
|
|
goto_bottom_frame_cb(GtkWidget *w _U_, gpointer d _U_)
|
|
{
|
|
cf_goto_bottom_frame();
|
|
}
|
|
|
|
void
|
|
goto_next_frame_cb(GtkWidget *w _U_, gpointer d _U_)
|
|
{
|
|
packet_list_next();
|
|
}
|
|
|
|
void
|
|
goto_previous_frame_cb(GtkWidget *w _U_, gpointer d _U_)
|
|
{
|
|
packet_list_prev();
|
|
}
|
|
|