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