5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
32 #include "gtk/gtkglobals.h"
33 #include "gtk/find_dlg.h"
34 #include "gtk/color_dlg.h"
35 #include "gtk/filter_utils.h"
37 #include "gtk/old-gtk-compat.h"
40 apply_selected_filter (guint callback_action, char *filter)
44 const char *current_filter;
46 action = FILTER_ACTION(callback_action);
47 type = FILTER_ACTYPE(callback_action);
49 current_filter = gtk_entry_get_text(GTK_ENTRY(main_display_filter_widget));
53 str = g_strdup_printf("%s", filter);
55 case ACTYPE_NOT_SELECTED:
56 str = g_strdup_printf("!(%s)", filter);
58 case ACTYPE_AND_SELECTED:
59 if ((!current_filter) || (0 == strlen(current_filter)))
60 str = g_strdup_printf("%s", filter);
62 str = g_strdup_printf("(%s) && (%s)", current_filter, filter);
64 case ACTYPE_OR_SELECTED:
65 if ((!current_filter) || (0 == strlen(current_filter)))
66 str = g_strdup_printf("%s", filter);
68 str = g_strdup_printf("(%s) || (%s)", current_filter, filter);
70 case ACTYPE_AND_NOT_SELECTED:
71 if ((!current_filter) || (0 == strlen(current_filter)))
72 str = g_strdup_printf("!(%s)", filter);
74 str = g_strdup_printf("(%s) && !(%s)", current_filter, filter);
76 case ACTYPE_OR_NOT_SELECTED:
77 if ((!current_filter) || (0 == strlen(current_filter)))
78 str = g_strdup_printf("!(%s)", filter);
80 str = g_strdup_printf("(%s) || !(%s)", current_filter, filter);
86 gtk_entry_set_text(GTK_ENTRY(main_display_filter_widget), str);
87 main_filter_packets(&cfile, str, FALSE);
88 gdk_window_raise(gtk_widget_get_window(top_level));
91 gtk_entry_set_text(GTK_ENTRY(main_display_filter_widget), str);
93 case ACTION_FIND_FRAME:
94 find_frame_with_filter(str);
96 case ACTION_FIND_NEXT:
97 cf_find_packet_dfilter_string(&cfile, str, SD_FORWARD);
99 case ACTION_FIND_PREVIOUS:
100 cf_find_packet_dfilter_string(&cfile, str, SD_BACKWARD);
102 case ACTION_COLORIZE:
103 color_display_with_filter(str);