2 * packet history related functions 2004 Ulf Lamping
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1998 Gerald Combs
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 #include "ui/gtk/main.h"
28 #include "ui/gtk/packet_history.h"
32 static GList *history_current = NULL;
33 static GList *history_list = NULL;
34 static gboolean ignore_jump = FALSE;
38 /* print the complete packet history to console */
39 static void history_print(void) {
40 GList *current = g_list_first(history_list);
45 if(current == history_current) {
46 printf(" Row: %u *\n", GPOINTER_TO_INT(current->data));
48 printf(" Row: %u\n", GPOINTER_TO_INT(current->data));
50 current = g_list_next(current);
56 /* adjust menu and toolbar sensitivity depending on the history entries */
57 static void adjust_menus(void) {
60 main_set_for_packet_history(
61 (g_list_previous(history_current) != NULL),
62 (g_list_next(history_current) != NULL));
64 /* we don't have any history */
65 main_set_for_packet_history(FALSE, FALSE);
68 /* history_print(); */
72 /* clear the history list from the given entry to the end of the list */
73 static void clear_list(GList *current) {
78 next_packet = g_list_next(current);
79 history_list = g_list_remove(history_list, current->data);
80 current = next_packet;
85 /* add an entry to the history list */
86 void packet_history_add(gint row) {
89 /* Not a valid row number */
94 /* we jumping back and forward in history, so don't change list */
98 if (history_current) {
99 /* clear list behind current position */
100 clear_list(g_list_next(history_current));
102 /* ignore duplicates */
103 if(GPOINTER_TO_INT(history_current->data) == row) {
110 history_list = g_list_append(history_list, GINT_TO_POINTER(row));
111 history_current = g_list_last(history_list);
117 void packet_history_clear(void) {
119 /* clear "old" list */
120 clear_list(history_list);
121 history_current = NULL;
123 /* add the currently selected first row */
124 packet_history_add(0);
130 static void packet_history_back(void) {
133 if(history_current) {
134 previous = g_list_previous(history_current);
136 /* do we have a previous entry */
138 history_current = previous;
140 /* goto that packet but don't change history */
142 cf_goto_frame(&cfile, GPOINTER_TO_INT(previous->data));
151 static void packet_history_forward(void) {
154 if(history_current) {
155 next = g_list_next(history_current);
157 /* do we have a forward entry? */
159 history_current = next;
161 /* goto that packet but don't change history */
163 cf_goto_frame(&cfile, GPOINTER_TO_INT(next->data));
172 void history_forward_cb(GtkWidget *widget _U_, gpointer data _U_) {
173 packet_history_forward();
177 void history_back_cb(GtkWidget *widget _U_, gpointer data _U_) {
178 packet_history_back();
183 * Editor modelines - http://www.wireshark.org/tools/modelines.html
188 * indent-tabs-mode: nil
191 * vi: set shiftwidth=4 tabstop=8 expandtab:
192 * :indentSize=4:tabSize=8:noTabs=true: