2 * packet history related functions 2004 Ulf Lamping
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34 #include "../globals.h"
36 #include "gtk/menus.h"
37 #include "gtk/packet_history.h"
40 static GList *history_current = NULL;
41 static GList *history_list = NULL;
42 static gboolean ignore_jump = FALSE;
46 /* print the complete packet history to console */
47 static void history_print(void) {
48 GList *current = g_list_first(history_list);
53 if(current == history_current) {
54 printf(" Row: %u *\n", GPOINTER_TO_INT(current->data));
56 printf(" Row: %u\n", GPOINTER_TO_INT(current->data));
58 current = g_list_next(current);
64 /* adjust menu and toolbar sensitivity depending on the history entries */
65 static void adjust_menus(void) {
68 set_menus_for_packet_history(
69 (g_list_previous(history_current) != NULL),
70 (g_list_next(history_current) != NULL));
72 /* we don't have any history */
73 set_menus_for_packet_history(FALSE, FALSE);
76 /* history_print(); */
80 /* clear the history list from the given entry to the end of the list */
81 static void clear_list(GList *current) {
86 next_packet = g_list_next(current);
87 history_list = g_list_remove(history_list, current->data);
88 current = next_packet;
93 /* add an entry to the history list */
94 void packet_history_add(gint row) {
97 /* Not a valid row number */
102 /* we jumping back and forward in history, so don't change list */
106 if (history_current) {
107 /* clear list behind current position */
108 clear_list(g_list_next(history_current));
110 /* ignore duplicates */
111 if(GPOINTER_TO_INT(history_current->data) == row) {
118 history_list = g_list_append(history_list, GINT_TO_POINTER(row));
119 history_current = g_list_last(history_list);
125 void packet_history_clear(void) {
127 /* clear "old" list */
128 clear_list(history_list);
129 history_current = NULL;
131 /* add the currently selected first row */
132 packet_history_add(0);
138 static void packet_history_back(void) {
141 if(history_current) {
142 previous = g_list_previous(history_current);
144 /* do we have a previous entry */
146 history_current = previous;
148 /* goto that packet but don't change history */
150 cf_goto_frame(&cfile, GPOINTER_TO_INT(previous->data));
159 static void packet_history_forward(void) {
162 if(history_current) {
163 next = g_list_next(history_current);
165 /* do we have a forward entry? */
167 history_current = next;
169 /* goto that packet but don't change history */
171 cf_goto_frame(&cfile, GPOINTER_TO_INT(next->data));
180 void history_forward_cb(GtkWidget *widget _U_, gpointer data _U_) {
181 packet_history_forward();
185 void history_back_cb(GtkWidget *widget _U_, gpointer data _U_) {
186 packet_history_back();