2 * packet history related functions 2004 Ulf Lamping
6 * Ethereal - Network traffic analyzer
7 * By Gerald Combs <gerald@ethereal.com>
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.
37 #include "packet_history.h"
40 GList *history_current = NULL;
41 GList *history_list = NULL;
42 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 /* we jumping back and forward in history, so don't change list */
101 if (history_current) {
102 /* clear list behind current position */
103 clear_list(g_list_next(history_current));
105 /* ignore duplicates */
106 if(GPOINTER_TO_INT(history_current->data) == row) {
113 history_list = g_list_append(history_list, GINT_TO_POINTER(row));
114 history_current = g_list_last(history_list);
120 void packet_history_clear(void) {
122 /* clear "old" list */
123 clear_list(history_list);
124 history_current = NULL;
126 /* add the currently selected first row */
127 packet_history_add(0);
133 void packet_history_back(void) {
136 if(history_current) {
137 previous = g_list_previous(history_current);
139 /* do we have a previous entry */
141 history_current = previous;
143 /* goto that packet but don't change history */
145 cf_goto_frame(&cfile, GPOINTER_TO_INT(previous->data) +1);
154 void packet_history_forward(void) {
157 if(history_current) {
158 next = g_list_next(history_current);
160 /* do we have a forward entry? */
162 history_current = next;
164 /* goto that packet but don't change history */
166 cf_goto_frame(&cfile, GPOINTER_TO_INT(next->data) +1);
175 void history_forward_cb(GtkWidget *widget _U_, gpointer data _U_) {
176 packet_history_forward();
180 void history_back_cb(GtkWidget *widget _U_, gpointer data _U_) {
181 packet_history_back();