1 /* cfilter_combo_utils.c
2 * Capture filter combo box routines
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.
35 #include "gtk/gtkglobals.h"
36 #include "gtk/cfilter_combo_utils.h"
37 #include "gtk/recent.h"
40 /* XXX: use a preference for this setting! */
41 static guint cfilter_combo_max_recent = 20;
44 cfilter_combo_add(gchar *s) {
46 GList *fl = g_object_get_data(G_OBJECT(top_level), E_CFILTER_FL_KEY);
48 li = g_list_first(fl);
50 /* If the filter is already in the list, remove the old one and
51 * append the new one at the latest position (at g_list_append() below) */
52 if (li->data && strcmp(s, li->data) == 0) {
53 fl = g_list_remove(fl, li->data);
58 fl = g_list_append(fl, s);
59 g_object_set_data(G_OBJECT(top_level), E_CFILTER_FL_KEY, fl);
64 /* write all non empty capture filters (until maximum count)
65 * of the combo box GList to the user's recent file */
67 cfilter_combo_recent_write_all(FILE *rf) {
68 GList *cfilter_list = g_object_get_data(G_OBJECT(top_level), E_CFILTER_FL_KEY);
72 /* write all non empty capture filter strings to the recent file (until max count) */
73 li = g_list_first(cfilter_list);
74 while (li && (max_count++ <= cfilter_combo_max_recent) ) {
75 if (li->data && strlen(li->data)) {
76 fprintf (rf, RECENT_KEY_CAPTURE_FILTER ": %s\n", (char *)li->data);
82 /* add a capture filter coming from the user's recent file to the cfilter combo box */
84 cfilter_combo_add_recent(gchar *s) {
89 if (!cfilter_combo_add(dup)) {