2004-07-19 21:42:01 +00:00
|
|
|
/* filter_dlg.c
|
|
|
|
* Dialog boxes for (display and capture) filter editing
|
1998-09-16 02:39:15 +00:00
|
|
|
*
|
2004-07-18 00:24:25 +00:00
|
|
|
* $Id$
|
1998-09-16 03:22:19 +00:00
|
|
|
*
|
2006-05-21 05:12:17 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
1998-09-16 02:39:15 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1998-09-16 02:39:15 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1998-09-16 02:39:15 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1998-09-16 02:39:15 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
Have separate capture and display filter lists; some filter dialog boxes
use the capture filter lists, and others use the display filter list, as
appropriate.
Have separate menu items for editing the capture and display filter
lists.
Have separate "~/.ethereal/cfilters" and "~/.ethereal/dfilters" files
for the two lists; if either of those files isn't found, we try
"~/.ethereal/filters", which means that you will start out with two
identical lists holding all your filters - if certain filters belong
only in one list, you'll have to delete them by hand from the other
list.
Do I/O error checking when reading and writing filter lists; when
writing a filter list, write it to a new file, and then rename the new
file on top of the old file, so that you don't lose your old filter list
if, for example, you run out of disk space or disk quota.
svn path=/trunk/; revision=2948
2001-01-28 09:13:10 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
1998-09-16 02:39:15 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2001-10-23 05:01:02 +00:00
|
|
|
#include <epan/filesystem.h>
|
2006-10-03 19:53:10 +00:00
|
|
|
#include <epan/prefs.h>
|
2008-10-10 17:00:38 +00:00
|
|
|
#include <epan/proto.h>
|
1998-09-16 02:39:15 +00:00
|
|
|
|
2008-04-13 01:54:20 +00:00
|
|
|
#include "../filters.h"
|
|
|
|
#include "../simple_dialog.h"
|
|
|
|
|
|
|
|
#include "gtk/main.h"
|
|
|
|
#include "gtk/main_statusbar.h"
|
|
|
|
#include "gtk/filter_dlg.h"
|
|
|
|
#include "gtk/dlg_utils.h"
|
|
|
|
#include "gtk/gui_utils.h"
|
|
|
|
#include "gtk/dfilter_expr_dlg.h"
|
|
|
|
#include "gtk/stock_icons.h"
|
|
|
|
#include "gtk/gtkglobals.h"
|
|
|
|
#include "gtk/help_dlg.h"
|
2008-07-22 15:19:10 +00:00
|
|
|
#include "gtk/filter_autocomplete.h"
|
2008-04-13 01:54:20 +00:00
|
|
|
|
2003-01-15 05:20:19 +00:00
|
|
|
#define E_FILT_DIALOG_PTR_KEY "filter_dialog_ptr"
|
|
|
|
#define E_FILT_BUTTON_PTR_KEY "filter_button_ptr"
|
In the process of destroying a filter editing dialog box, we get a
selection change event on the list of filters. Unfortunately, this can
happen after some other widgets in that dialog box have already been
destroyed - including some of the widgets that such a selection change
event can change.
This sometimes happened when "filter_prefs_delete()" hadn't been called,
so the mechanism we had been using, with a Boolean datum attached to the
dialog box, set in "filter_prefs_delete()" before we actually destroy
the dialog box, wasn't sufficient to keep that from happening.
Attach to the top-level window data items containing pointers to the
widgets changed when a filter is selected from the list, give each of
those widgets their own destroy callbacks, clear the pointer attached to
the top-level widget when the widget is destroyed, and don't do anything
to the widget when a filter is selected from the list if the pointer for
that widget is null, as that means the widget's been destroyed and we
*can't* do anything to it.
Not all filter editing dialogs created on behalf of a "Filter:" button
next to a text entry box should, when you click "OK", activate the text
entry box; if the text entry box is part of a dialog box with multiple
widgets, the user might not have filled in all of the items in that
dialog box, so you shouldn't activate it for them. Add a mechanism by
which, when creating a filter editing dialog box, you can specify
whether the "OK" button should just fill in the text entry box or should
fill it in and also activate it.
svn path=/trunk/; revision=2922
2001-01-21 01:45:07 +00:00
|
|
|
#define E_FILT_PARENT_FILTER_TE_KEY "filter_parent_filter_te"
|
|
|
|
#define E_FILT_CONSTRUCT_ARGS_KEY "filter_construct_args"
|
2001-01-21 03:30:24 +00:00
|
|
|
#define E_FILT_LIST_ITEM_MODEL_KEY "filter_list_item_model"
|
In the process of destroying a filter editing dialog box, we get a
selection change event on the list of filters. Unfortunately, this can
happen after some other widgets in that dialog box have already been
destroyed - including some of the widgets that such a selection change
event can change.
This sometimes happened when "filter_prefs_delete()" hadn't been called,
so the mechanism we had been using, with a Boolean datum attached to the
dialog box, set in "filter_prefs_delete()" before we actually destroy
the dialog box, wasn't sufficient to keep that from happening.
Attach to the top-level window data items containing pointers to the
widgets changed when a filter is selected from the list, give each of
those widgets their own destroy callbacks, clear the pointer attached to
the top-level widget when the widget is destroyed, and don't do anything
to the widget when a filter is selected from the list if the pointer for
that widget is null, as that means the widget's been destroyed and we
*can't* do anything to it.
Not all filter editing dialogs created on behalf of a "Filter:" button
next to a text entry box should, when you click "OK", activate the text
entry box; if the text entry box is part of a dialog box with multiple
widgets, the user might not have filled in all of the items in that
dialog box, so you shouldn't activate it for them. Add a mechanism by
which, when creating a filter editing dialog box, you can specify
whether the "OK" button should just fill in the text entry box or should
fill it in and also activate it.
svn path=/trunk/; revision=2922
2001-01-21 01:45:07 +00:00
|
|
|
#define E_FILT_LBL_KEY "filter_label"
|
|
|
|
#define E_FILT_FILTER_L_KEY "filter_filter_l"
|
|
|
|
#define E_FILT_CHG_BT_KEY "filter_chg_bt"
|
|
|
|
#define E_FILT_COPY_BT_KEY "filter_copy_bt"
|
|
|
|
#define E_FILT_DEL_BT_KEY "filter_del_bt"
|
|
|
|
#define E_FILT_NAME_TE_KEY "filter_name_te"
|
|
|
|
#define E_FILT_DBLFUNC_KEY "filter_dblfunc"
|
|
|
|
#define E_FILT_DBLARG_KEY "filter_dblarg"
|
2002-03-16 22:02:55 +00:00
|
|
|
#define E_FILT_DBLACTIVATE_KEY "filter_dblactivate"
|
1998-10-13 02:10:57 +00:00
|
|
|
|
1999-09-09 03:35:32 +00:00
|
|
|
typedef struct _filter_cb_data {
|
|
|
|
GList *fl;
|
|
|
|
GtkWidget *win;
|
|
|
|
} filter_cb_data;
|
|
|
|
|
2003-01-15 05:20:19 +00:00
|
|
|
static GtkWidget *filter_dialog_new(GtkWidget *button, GtkWidget *filter_te,
|
2006-10-01 17:59:30 +00:00
|
|
|
filter_list_type_t list_type,
|
2002-11-03 17:38:45 +00:00
|
|
|
construct_args_t *construct_args);
|
2002-03-16 22:02:55 +00:00
|
|
|
static void filter_dlg_dclick(GtkWidget *dummy, gpointer main_w_arg,
|
2009-05-01 16:36:04 +00:00
|
|
|
gpointer activate);
|
2006-10-03 21:03:08 +00:00
|
|
|
static void filter_dlg_ok_cb(GtkWidget *ok_bt, gpointer data);
|
|
|
|
static void filter_dlg_apply_cb(GtkWidget *apply_bt, gpointer data);
|
2002-05-02 23:49:21 +00:00
|
|
|
static void filter_apply(GtkWidget *main_w, gboolean destroy);
|
2006-10-03 19:53:10 +00:00
|
|
|
static void filter_dlg_save(filter_list_type_t list_type);
|
2001-01-02 01:32:21 +00:00
|
|
|
static void filter_dlg_save_cb(GtkWidget *save_bt, gpointer parent_w);
|
2004-01-25 12:25:57 +00:00
|
|
|
static void filter_dlg_destroy_cb(GtkWidget *win, gpointer data);
|
1998-10-13 02:10:57 +00:00
|
|
|
|
2006-10-01 17:59:30 +00:00
|
|
|
static gboolean
|
|
|
|
filter_dlg_delete_event_cb(GtkWidget *prefs_w, GdkEvent *event, gpointer data);
|
|
|
|
static void
|
|
|
|
filter_dlg_cancel_cb(GtkWidget *cancel_bt, gpointer data);
|
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
static gint filter_sel_list_button_cb(GtkWidget *, GdkEventButton *,
|
|
|
|
gpointer);
|
|
|
|
static void filter_sel_list_cb(GtkTreeSelection *, gpointer);
|
|
|
|
static void filter_new_bt_clicked_cb(GtkWidget *, gpointer);
|
|
|
|
static void filter_del_bt_clicked_cb(GtkWidget *, gpointer);
|
2004-01-25 15:10:36 +00:00
|
|
|
static void filter_name_te_changed_cb(GtkWidget *, gpointer);
|
2000-02-12 06:46:54 +00:00
|
|
|
|
2001-06-27 10:00:14 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
2001-01-02 01:32:21 +00:00
|
|
|
/* Create a filter dialog for constructing a capture filter.
|
|
|
|
|
|
|
|
This is to be used as a callback for a button next to a text entry box,
|
|
|
|
which, when clicked, pops up this dialog to allow you to construct a
|
|
|
|
display filter by browsing the list of saved filters (the dialog
|
|
|
|
for constructing expressions assumes display filter syntax, not
|
|
|
|
capture filter syntax). The "OK" button sets the text entry box to the
|
|
|
|
constructed filter and activates that text entry box (which should have
|
2002-05-02 23:49:21 +00:00
|
|
|
no effect in the main capture dialog); this dialog is then dismissed. */
|
2001-01-02 01:32:21 +00:00
|
|
|
void
|
2002-03-05 11:56:00 +00:00
|
|
|
capture_filter_construct_cb(GtkWidget *w, gpointer user_data _U_)
|
2001-01-02 01:32:21 +00:00
|
|
|
{
|
2009-05-01 16:36:04 +00:00
|
|
|
GtkWidget *filter_browse_w;
|
|
|
|
GtkWidget *parent_filter_te;
|
|
|
|
/* No Apply button, and "OK" just sets our text widget, it doesn't
|
|
|
|
activate it (i.e., it doesn't cause us to try to open the file). */
|
|
|
|
static construct_args_t args = {
|
|
|
|
"Wireshark: Capture Filter",
|
|
|
|
FALSE,
|
|
|
|
FALSE,
|
2005-12-31 17:09:27 +00:00
|
|
|
FALSE
|
2009-05-01 16:36:04 +00:00
|
|
|
};
|
2001-01-02 01:32:21 +00:00
|
|
|
|
2009-05-01 16:36:04 +00:00
|
|
|
/* Has a filter dialog box already been opened for that button? */
|
|
|
|
filter_browse_w = g_object_get_data(G_OBJECT(w), E_FILT_DIALOG_PTR_KEY);
|
2001-01-02 01:32:21 +00:00
|
|
|
|
2009-05-01 16:36:04 +00:00
|
|
|
if (filter_browse_w != NULL) {
|
|
|
|
/* Yes. Just re-activate that dialog box. */
|
|
|
|
reactivate_window(filter_browse_w);
|
|
|
|
return;
|
|
|
|
}
|
2001-01-02 01:32:21 +00:00
|
|
|
|
2009-05-01 16:36:04 +00:00
|
|
|
/* No. Get the text entry attached to the button. */
|
|
|
|
parent_filter_te = g_object_get_data(G_OBJECT(w), E_FILT_TE_PTR_KEY);
|
2001-01-02 01:32:21 +00:00
|
|
|
|
2009-05-01 16:36:04 +00:00
|
|
|
/* Now create a new dialog, without an "Add Expression..." button. */
|
2009-11-10 12:05:25 +00:00
|
|
|
filter_dialog_new(w, parent_filter_te, CFILTER_LIST, &args);
|
2001-01-02 01:32:21 +00:00
|
|
|
}
|
2001-06-27 10:00:14 +00:00
|
|
|
#endif
|
2001-01-02 01:32:21 +00:00
|
|
|
|
|
|
|
/* Create a filter dialog for constructing a display filter.
|
|
|
|
|
|
|
|
This is to be used as a callback for a button next to a text entry box,
|
|
|
|
which, when clicked, pops up this dialog to allow you to construct a
|
|
|
|
display filter by browsing the list of saved filters and/or by adding
|
|
|
|
test expressions constructed with another dialog. The "OK" button
|
|
|
|
sets the text entry box to the constructed filter and activates that
|
|
|
|
text entry box, causing the filter to be used; this dialog is then
|
|
|
|
dismissed.
|
|
|
|
|
|
|
|
If "wants_apply_button" is non-null, we add an "Apply" button that
|
2002-05-02 23:49:21 +00:00
|
|
|
acts like "OK" but doesn't dismiss this dialog. */
|
2003-01-15 05:58:50 +00:00
|
|
|
void
|
In the process of destroying a filter editing dialog box, we get a
selection change event on the list of filters. Unfortunately, this can
happen after some other widgets in that dialog box have already been
destroyed - including some of the widgets that such a selection change
event can change.
This sometimes happened when "filter_prefs_delete()" hadn't been called,
so the mechanism we had been using, with a Boolean datum attached to the
dialog box, set in "filter_prefs_delete()" before we actually destroy
the dialog box, wasn't sufficient to keep that from happening.
Attach to the top-level window data items containing pointers to the
widgets changed when a filter is selected from the list, give each of
those widgets their own destroy callbacks, clear the pointer attached to
the top-level widget when the widget is destroyed, and don't do anything
to the widget when a filter is selected from the list if the pointer for
that widget is null, as that means the widget's been destroyed and we
*can't* do anything to it.
Not all filter editing dialogs created on behalf of a "Filter:" button
next to a text entry box should, when you click "OK", activate the text
entry box; if the text entry box is part of a dialog box with multiple
widgets, the user might not have filled in all of the items in that
dialog box, so you shouldn't activate it for them. Add a mechanism by
which, when creating a filter editing dialog box, you can specify
whether the "OK" button should just fill in the text entry box or should
fill it in and also activate it.
svn path=/trunk/; revision=2922
2001-01-21 01:45:07 +00:00
|
|
|
display_filter_construct_cb(GtkWidget *w, gpointer construct_args_ptr)
|
Split "filter_dialog_cb()" into "filter_dialog_cb()", which pops up a
"global" dialog box when "Edit:Filters" is selected, so that the list of
filters can be edited, and "filter_browse_cb()", which pops up a dialog
box associated with a "Filter:" button and a text entry widget attached
to that button, so that a filter can be selected or saved (although it
also supports the same editing that the "global" dialog box does).
Have "filter_dialog_cb()" connect the window in which the "Filter:"
button lives and the filter dialog box, so that:
if the window in which the "Filter:" button lives goes away, so
does the filter dialog box (as it no longer has a text widget
into which it can stuff the selected filter);
if the "Filter:" button is clicked when there's already a filter
dialog box open, we just reactivate that existing dialog box
rather than popping up a new one.
Also keep a pointer to the "global" filter dialog box, so that we also
arrange that there's only one of them (by reactivating the existing on
if "Edit:Filters" is selected when there's already a "global" filter
dialog box open).
Keep around pointers to the dialog boxes that contain the "Filter:"
buttons, so that we can arrange that there be only one of them (that was
a side-effect of an earlier attempt at fixing the problems described
above, but it's still useful for keeping multiple competing dialog boxes
from being open - there's more of that to be done).
Make the pointer to the "Open Capture File" dialog box widget static to
"file_dlg.c" - nobody outside of "file_dlg.c cares about it.
svn path=/trunk/; revision=1774
2000-04-01 12:03:42 +00:00
|
|
|
{
|
2009-05-01 16:36:04 +00:00
|
|
|
construct_args_t *construct_args = construct_args_ptr;
|
|
|
|
GtkWidget *filter_browse_w;
|
|
|
|
GtkWidget *parent_filter_te;
|
|
|
|
|
|
|
|
/* Has a filter dialog box already been opened for the button? */
|
|
|
|
filter_browse_w = g_object_get_data(G_OBJECT(w), E_FILT_DIALOG_PTR_KEY);
|
|
|
|
|
|
|
|
if (filter_browse_w != NULL) {
|
|
|
|
/* Yes. Just re-activate that dialog box. */
|
|
|
|
reactivate_window(filter_browse_w);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* No. Get the text entry attached to the button. */
|
|
|
|
parent_filter_te = g_object_get_data(G_OBJECT(w), E_FILT_TE_PTR_KEY);
|
|
|
|
|
|
|
|
/* Now create a new dialog, possibly with an "Apply" button, and
|
|
|
|
definitely with an "Add Expression..." button. */
|
2009-11-10 12:05:25 +00:00
|
|
|
filter_dialog_new(w, parent_filter_te, DFILTER_LIST, construct_args);
|
Split "filter_dialog_cb()" into "filter_dialog_cb()", which pops up a
"global" dialog box when "Edit:Filters" is selected, so that the list of
filters can be edited, and "filter_browse_cb()", which pops up a dialog
box associated with a "Filter:" button and a text entry widget attached
to that button, so that a filter can be selected or saved (although it
also supports the same editing that the "global" dialog box does).
Have "filter_dialog_cb()" connect the window in which the "Filter:"
button lives and the filter dialog box, so that:
if the window in which the "Filter:" button lives goes away, so
does the filter dialog box (as it no longer has a text widget
into which it can stuff the selected filter);
if the "Filter:" button is clicked when there's already a filter
dialog box open, we just reactivate that existing dialog box
rather than popping up a new one.
Also keep a pointer to the "global" filter dialog box, so that we also
arrange that there's only one of them (by reactivating the existing on
if "Edit:Filters" is selected when there's already a "global" filter
dialog box open).
Keep around pointers to the dialog boxes that contain the "Filter:"
buttons, so that we can arrange that there be only one of them (that was
a side-effect of an earlier attempt at fixing the problems described
above, but it's still useful for keeping multiple competing dialog boxes
from being open - there's more of that to be done).
Make the pointer to the "Open Capture File" dialog box widget static to
"file_dlg.c" - nobody outside of "file_dlg.c cares about it.
svn path=/trunk/; revision=1774
2000-04-01 12:03:42 +00:00
|
|
|
}
|
|
|
|
|
2003-01-15 05:20:19 +00:00
|
|
|
/* Should be called when a button that creates filters is destroyed; it
|
2004-06-01 17:33:37 +00:00
|
|
|
destroys any filter dialog created by that button. */
|
2003-01-15 05:20:19 +00:00
|
|
|
void
|
|
|
|
filter_button_destroy_cb(GtkWidget *button, gpointer user_data _U_)
|
|
|
|
{
|
2009-05-01 16:36:04 +00:00
|
|
|
GtkWidget *filter_w;
|
2003-01-15 05:20:19 +00:00
|
|
|
|
2009-05-01 16:36:04 +00:00
|
|
|
/* Is there a filter edit/selection dialog associated with this
|
|
|
|
button? */
|
|
|
|
filter_w = g_object_get_data(G_OBJECT(button), E_FILT_DIALOG_PTR_KEY);
|
2003-01-15 05:20:19 +00:00
|
|
|
|
2009-05-01 16:36:04 +00:00
|
|
|
if (filter_w != NULL) {
|
|
|
|
/* Yes. Break the association, and destroy the dialog. */
|
|
|
|
g_object_set_data(G_OBJECT(button), E_FILT_DIALOG_PTR_KEY, NULL);
|
|
|
|
window_destroy(filter_w);
|
|
|
|
}
|
2003-01-15 05:20:19 +00:00
|
|
|
}
|
|
|
|
|
2001-06-27 10:00:14 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
Have separate capture and display filter lists; some filter dialog boxes
use the capture filter lists, and others use the display filter list, as
appropriate.
Have separate menu items for editing the capture and display filter
lists.
Have separate "~/.ethereal/cfilters" and "~/.ethereal/dfilters" files
for the two lists; if either of those files isn't found, we try
"~/.ethereal/filters", which means that you will start out with two
identical lists holding all your filters - if certain filters belong
only in one list, you'll have to delete them by hand from the other
list.
Do I/O error checking when reading and writing filter lists; when
writing a filter list, write it to a new file, and then rename the new
file on top of the old file, so that you don't lose your old filter list
if, for example, you run out of disk space or disk quota.
svn path=/trunk/; revision=2948
2001-01-28 09:13:10 +00:00
|
|
|
static GtkWidget *global_cfilter_w;
|
|
|
|
|
|
|
|
/* Create a filter dialog for editing capture filters; this is to be used
|
|
|
|
as a callback for menu items, toolbars, etc.. */
|
|
|
|
void
|
2002-03-05 11:56:00 +00:00
|
|
|
cfilter_dialog_cb(GtkWidget *w _U_)
|
Have separate capture and display filter lists; some filter dialog boxes
use the capture filter lists, and others use the display filter list, as
appropriate.
Have separate menu items for editing the capture and display filter
lists.
Have separate "~/.ethereal/cfilters" and "~/.ethereal/dfilters" files
for the two lists; if either of those files isn't found, we try
"~/.ethereal/filters", which means that you will start out with two
identical lists holding all your filters - if certain filters belong
only in one list, you'll have to delete them by hand from the other
list.
Do I/O error checking when reading and writing filter lists; when
writing a filter list, write it to a new file, and then rename the new
file on top of the old file, so that you don't lose your old filter list
if, for example, you run out of disk space or disk quota.
svn path=/trunk/; revision=2948
2001-01-28 09:13:10 +00:00
|
|
|
{
|
2009-05-01 16:36:04 +00:00
|
|
|
/* No Apply button, and there's no text widget to set, much less
|
|
|
|
activate, on "OK". */
|
|
|
|
static construct_args_t args = {
|
|
|
|
"Wireshark: Capture Filter",
|
|
|
|
FALSE,
|
|
|
|
FALSE,
|
2005-12-31 17:09:27 +00:00
|
|
|
FALSE
|
2009-05-01 16:36:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Has a filter dialog box already been opened for editing
|
|
|
|
capture filters? */
|
|
|
|
if (global_cfilter_w != NULL) {
|
|
|
|
/* Yes. Just reactivate it. */
|
|
|
|
reactivate_window(global_cfilter_w);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* No. Create one; we didn't pop this up as a result of pressing
|
|
|
|
* a button next to some text entry field, so don't associate it
|
|
|
|
* with a text entry field or button.
|
|
|
|
*/
|
|
|
|
global_cfilter_w = filter_dialog_new(NULL, NULL, CFILTER_LIST, &args);
|
Have separate capture and display filter lists; some filter dialog boxes
use the capture filter lists, and others use the display filter list, as
appropriate.
Have separate menu items for editing the capture and display filter
lists.
Have separate "~/.ethereal/cfilters" and "~/.ethereal/dfilters" files
for the two lists; if either of those files isn't found, we try
"~/.ethereal/filters", which means that you will start out with two
identical lists holding all your filters - if certain filters belong
only in one list, you'll have to delete them by hand from the other
list.
Do I/O error checking when reading and writing filter lists; when
writing a filter list, write it to a new file, and then rename the new
file on top of the old file, so that you don't lose your old filter list
if, for example, you run out of disk space or disk quota.
svn path=/trunk/; revision=2948
2001-01-28 09:13:10 +00:00
|
|
|
}
|
2001-06-27 10:00:14 +00:00
|
|
|
#endif
|
Have separate capture and display filter lists; some filter dialog boxes
use the capture filter lists, and others use the display filter list, as
appropriate.
Have separate menu items for editing the capture and display filter
lists.
Have separate "~/.ethereal/cfilters" and "~/.ethereal/dfilters" files
for the two lists; if either of those files isn't found, we try
"~/.ethereal/filters", which means that you will start out with two
identical lists holding all your filters - if certain filters belong
only in one list, you'll have to delete them by hand from the other
list.
Do I/O error checking when reading and writing filter lists; when
writing a filter list, write it to a new file, and then rename the new
file on top of the old file, so that you don't lose your old filter list
if, for example, you run out of disk space or disk quota.
svn path=/trunk/; revision=2948
2001-01-28 09:13:10 +00:00
|
|
|
|
|
|
|
/* Create a filter dialog for editing display filters; this is to be used
|
|
|
|
as a callback for menu items, toolbars, etc.. */
|
1999-12-10 06:28:24 +00:00
|
|
|
void
|
2002-03-05 11:56:00 +00:00
|
|
|
dfilter_dialog_cb(GtkWidget *w _U_)
|
Split "filter_dialog_cb()" into "filter_dialog_cb()", which pops up a
"global" dialog box when "Edit:Filters" is selected, so that the list of
filters can be edited, and "filter_browse_cb()", which pops up a dialog
box associated with a "Filter:" button and a text entry widget attached
to that button, so that a filter can be selected or saved (although it
also supports the same editing that the "global" dialog box does).
Have "filter_dialog_cb()" connect the window in which the "Filter:"
button lives and the filter dialog box, so that:
if the window in which the "Filter:" button lives goes away, so
does the filter dialog box (as it no longer has a text widget
into which it can stuff the selected filter);
if the "Filter:" button is clicked when there's already a filter
dialog box open, we just reactivate that existing dialog box
rather than popping up a new one.
Also keep a pointer to the "global" filter dialog box, so that we also
arrange that there's only one of them (by reactivating the existing on
if "Edit:Filters" is selected when there's already a "global" filter
dialog box open).
Keep around pointers to the dialog boxes that contain the "Filter:"
buttons, so that we can arrange that there be only one of them (that was
a side-effect of an earlier attempt at fixing the problems described
above, but it's still useful for keeping multiple competing dialog boxes
from being open - there's more of that to be done).
Make the pointer to the "Open Capture File" dialog box widget static to
"file_dlg.c" - nobody outside of "file_dlg.c cares about it.
svn path=/trunk/; revision=1774
2000-04-01 12:03:42 +00:00
|
|
|
{
|
2009-05-01 16:36:04 +00:00
|
|
|
static construct_args_t args = {
|
|
|
|
"Wireshark: Display Filter",
|
|
|
|
TRUE,
|
|
|
|
TRUE,
|
2005-12-31 17:09:27 +00:00
|
|
|
FALSE
|
2009-05-01 16:36:04 +00:00
|
|
|
};
|
In the process of destroying a filter editing dialog box, we get a
selection change event on the list of filters. Unfortunately, this can
happen after some other widgets in that dialog box have already been
destroyed - including some of the widgets that such a selection change
event can change.
This sometimes happened when "filter_prefs_delete()" hadn't been called,
so the mechanism we had been using, with a Boolean datum attached to the
dialog box, set in "filter_prefs_delete()" before we actually destroy
the dialog box, wasn't sufficient to keep that from happening.
Attach to the top-level window data items containing pointers to the
widgets changed when a filter is selected from the list, give each of
those widgets their own destroy callbacks, clear the pointer attached to
the top-level widget when the widget is destroyed, and don't do anything
to the widget when a filter is selected from the list if the pointer for
that widget is null, as that means the widget's been destroyed and we
*can't* do anything to it.
Not all filter editing dialogs created on behalf of a "Filter:" button
next to a text entry box should, when you click "OK", activate the text
entry box; if the text entry box is part of a dialog box with multiple
widgets, the user might not have filled in all of the items in that
dialog box, so you shouldn't activate it for them. Add a mechanism by
which, when creating a filter editing dialog box, you can specify
whether the "OK" button should just fill in the text entry box or should
fill it in and also activate it.
svn path=/trunk/; revision=2922
2001-01-21 01:45:07 +00:00
|
|
|
|
2008-04-11 16:04:54 +00:00
|
|
|
display_filter_construct_cb(g_object_get_data(G_OBJECT(top_level), E_FILT_BT_PTR_KEY), &args);
|
Split "filter_dialog_cb()" into "filter_dialog_cb()", which pops up a
"global" dialog box when "Edit:Filters" is selected, so that the list of
filters can be edited, and "filter_browse_cb()", which pops up a dialog
box associated with a "Filter:" button and a text entry widget attached
to that button, so that a filter can be selected or saved (although it
also supports the same editing that the "global" dialog box does).
Have "filter_dialog_cb()" connect the window in which the "Filter:"
button lives and the filter dialog box, so that:
if the window in which the "Filter:" button lives goes away, so
does the filter dialog box (as it no longer has a text widget
into which it can stuff the selected filter);
if the "Filter:" button is clicked when there's already a filter
dialog box open, we just reactivate that existing dialog box
rather than popping up a new one.
Also keep a pointer to the "global" filter dialog box, so that we also
arrange that there's only one of them (by reactivating the existing on
if "Edit:Filters" is selected when there's already a "global" filter
dialog box open).
Keep around pointers to the dialog boxes that contain the "Filter:"
buttons, so that we can arrange that there be only one of them (that was
a side-effect of an earlier attempt at fixing the problems described
above, but it's still useful for keeping multiple competing dialog boxes
from being open - there's more of that to be done).
Make the pointer to the "Open Capture File" dialog box widget static to
"file_dlg.c" - nobody outside of "file_dlg.c cares about it.
svn path=/trunk/; revision=1774
2000-04-01 12:03:42 +00:00
|
|
|
}
|
|
|
|
|
Have separate capture and display filter lists; some filter dialog boxes
use the capture filter lists, and others use the display filter list, as
appropriate.
Have separate menu items for editing the capture and display filter
lists.
Have separate "~/.ethereal/cfilters" and "~/.ethereal/dfilters" files
for the two lists; if either of those files isn't found, we try
"~/.ethereal/filters", which means that you will start out with two
identical lists holding all your filters - if certain filters belong
only in one list, you'll have to delete them by hand from the other
list.
Do I/O error checking when reading and writing filter lists; when
writing a filter list, write it to a new file, and then rename the new
file on top of the old file, so that you don't lose your old filter list
if, for example, you run out of disk space or disk quota.
svn path=/trunk/; revision=2948
2001-01-28 09:13:10 +00:00
|
|
|
/* List of capture filter dialogs, so that if the list of filters changes
|
|
|
|
(the model, if you will), we can update all of their lists displaying
|
|
|
|
the filters (the views). */
|
|
|
|
static GList *cfilter_dialogs;
|
|
|
|
|
|
|
|
/* List of display filter dialogs, so that if the list of filters changes
|
|
|
|
(the model, if you will), we can update all of their lists displaying
|
2001-01-21 03:30:24 +00:00
|
|
|
the filters (the views). */
|
Have separate capture and display filter lists; some filter dialog boxes
use the capture filter lists, and others use the display filter list, as
appropriate.
Have separate menu items for editing the capture and display filter
lists.
Have separate "~/.ethereal/cfilters" and "~/.ethereal/dfilters" files
for the two lists; if either of those files isn't found, we try
"~/.ethereal/filters", which means that you will start out with two
identical lists holding all your filters - if certain filters belong
only in one list, you'll have to delete them by hand from the other
list.
Do I/O error checking when reading and writing filter lists; when
writing a filter list, write it to a new file, and then rename the new
file on top of the old file, so that you don't lose your old filter list
if, for example, you run out of disk space or disk quota.
svn path=/trunk/; revision=2948
2001-01-28 09:13:10 +00:00
|
|
|
static GList *dfilter_dialogs;
|
2001-01-21 03:30:24 +00:00
|
|
|
|
|
|
|
static void
|
Have separate capture and display filter lists; some filter dialog boxes
use the capture filter lists, and others use the display filter list, as
appropriate.
Have separate menu items for editing the capture and display filter
lists.
Have separate "~/.ethereal/cfilters" and "~/.ethereal/dfilters" files
for the two lists; if either of those files isn't found, we try
"~/.ethereal/filters", which means that you will start out with two
identical lists holding all your filters - if certain filters belong
only in one list, you'll have to delete them by hand from the other
list.
Do I/O error checking when reading and writing filter lists; when
writing a filter list, write it to a new file, and then rename the new
file on top of the old file, so that you don't lose your old filter list
if, for example, you run out of disk space or disk quota.
svn path=/trunk/; revision=2948
2001-01-28 09:13:10 +00:00
|
|
|
remember_filter_dialog(GtkWidget *main_w, GList **filter_dialogs)
|
2001-01-21 03:30:24 +00:00
|
|
|
{
|
2009-05-01 16:36:04 +00:00
|
|
|
*filter_dialogs = g_list_append(*filter_dialogs, main_w);
|
2001-01-21 03:30:24 +00:00
|
|
|
}
|
|
|
|
|
Have separate capture and display filter lists; some filter dialog boxes
use the capture filter lists, and others use the display filter list, as
appropriate.
Have separate menu items for editing the capture and display filter
lists.
Have separate "~/.ethereal/cfilters" and "~/.ethereal/dfilters" files
for the two lists; if either of those files isn't found, we try
"~/.ethereal/filters", which means that you will start out with two
identical lists holding all your filters - if certain filters belong
only in one list, you'll have to delete them by hand from the other
list.
Do I/O error checking when reading and writing filter lists; when
writing a filter list, write it to a new file, and then rename the new
file on top of the old file, so that you don't lose your old filter list
if, for example, you run out of disk space or disk quota.
svn path=/trunk/; revision=2948
2001-01-28 09:13:10 +00:00
|
|
|
/* Remove a filter dialog from the specified list of filter_dialogs. */
|
2001-01-21 03:30:24 +00:00
|
|
|
static void
|
2006-10-01 17:59:30 +00:00
|
|
|
forget_filter_dialog(GtkWidget *main_w, filter_list_type_t list_type)
|
Have separate capture and display filter lists; some filter dialog boxes
use the capture filter lists, and others use the display filter list, as
appropriate.
Have separate menu items for editing the capture and display filter
lists.
Have separate "~/.ethereal/cfilters" and "~/.ethereal/dfilters" files
for the two lists; if either of those files isn't found, we try
"~/.ethereal/filters", which means that you will start out with two
identical lists holding all your filters - if certain filters belong
only in one list, you'll have to delete them by hand from the other
list.
Do I/O error checking when reading and writing filter lists; when
writing a filter list, write it to a new file, and then rename the new
file on top of the old file, so that you don't lose your old filter list
if, for example, you run out of disk space or disk quota.
svn path=/trunk/; revision=2948
2001-01-28 09:13:10 +00:00
|
|
|
{
|
2009-05-01 16:36:04 +00:00
|
|
|
switch (list_type) {
|
Have separate capture and display filter lists; some filter dialog boxes
use the capture filter lists, and others use the display filter list, as
appropriate.
Have separate menu items for editing the capture and display filter
lists.
Have separate "~/.ethereal/cfilters" and "~/.ethereal/dfilters" files
for the two lists; if either of those files isn't found, we try
"~/.ethereal/filters", which means that you will start out with two
identical lists holding all your filters - if certain filters belong
only in one list, you'll have to delete them by hand from the other
list.
Do I/O error checking when reading and writing filter lists; when
writing a filter list, write it to a new file, and then rename the new
file on top of the old file, so that you don't lose your old filter list
if, for example, you run out of disk space or disk quota.
svn path=/trunk/; revision=2948
2001-01-28 09:13:10 +00:00
|
|
|
|
2009-05-01 16:36:04 +00:00
|
|
|
case CFILTER_EDITED_LIST:
|
|
|
|
cfilter_dialogs = g_list_remove(cfilter_dialogs, main_w);
|
|
|
|
break;
|
Have separate capture and display filter lists; some filter dialog boxes
use the capture filter lists, and others use the display filter list, as
appropriate.
Have separate menu items for editing the capture and display filter
lists.
Have separate "~/.ethereal/cfilters" and "~/.ethereal/dfilters" files
for the two lists; if either of those files isn't found, we try
"~/.ethereal/filters", which means that you will start out with two
identical lists holding all your filters - if certain filters belong
only in one list, you'll have to delete them by hand from the other
list.
Do I/O error checking when reading and writing filter lists; when
writing a filter list, write it to a new file, and then rename the new
file on top of the old file, so that you don't lose your old filter list
if, for example, you run out of disk space or disk quota.
svn path=/trunk/; revision=2948
2001-01-28 09:13:10 +00:00
|
|
|
|
2009-05-01 16:36:04 +00:00
|
|
|
case DFILTER_EDITED_LIST:
|
|
|
|
dfilter_dialogs = g_list_remove(dfilter_dialogs, main_w);
|
|
|
|
break;
|
Have separate capture and display filter lists; some filter dialog boxes
use the capture filter lists, and others use the display filter list, as
appropriate.
Have separate menu items for editing the capture and display filter
lists.
Have separate "~/.ethereal/cfilters" and "~/.ethereal/dfilters" files
for the two lists; if either of those files isn't found, we try
"~/.ethereal/filters", which means that you will start out with two
identical lists holding all your filters - if certain filters belong
only in one list, you'll have to delete them by hand from the other
list.
Do I/O error checking when reading and writing filter lists; when
writing a filter list, write it to a new file, and then rename the new
file on top of the old file, so that you don't lose your old filter list
if, for example, you run out of disk space or disk quota.
svn path=/trunk/; revision=2948
2001-01-28 09:13:10 +00:00
|
|
|
|
2009-05-01 16:36:04 +00:00
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
break;
|
|
|
|
}
|
Have separate capture and display filter lists; some filter dialog boxes
use the capture filter lists, and others use the display filter list, as
appropriate.
Have separate menu items for editing the capture and display filter
lists.
Have separate "~/.ethereal/cfilters" and "~/.ethereal/dfilters" files
for the two lists; if either of those files isn't found, we try
"~/.ethereal/filters", which means that you will start out with two
identical lists holding all your filters - if certain filters belong
only in one list, you'll have to delete them by hand from the other
list.
Do I/O error checking when reading and writing filter lists; when
writing a filter list, write it to a new file, and then rename the new
file on top of the old file, so that you don't lose your old filter list
if, for example, you run out of disk space or disk quota.
svn path=/trunk/; revision=2948
2001-01-28 09:13:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the dialog list corresponding to a particular filter list. */
|
|
|
|
static GList *
|
2006-10-01 17:59:30 +00:00
|
|
|
get_filter_dialog_list(filter_list_type_t list_type)
|
2001-01-21 03:30:24 +00:00
|
|
|
{
|
2009-05-01 16:36:04 +00:00
|
|
|
switch (list_type) {
|
Have separate capture and display filter lists; some filter dialog boxes
use the capture filter lists, and others use the display filter list, as
appropriate.
Have separate menu items for editing the capture and display filter
lists.
Have separate "~/.ethereal/cfilters" and "~/.ethereal/dfilters" files
for the two lists; if either of those files isn't found, we try
"~/.ethereal/filters", which means that you will start out with two
identical lists holding all your filters - if certain filters belong
only in one list, you'll have to delete them by hand from the other
list.
Do I/O error checking when reading and writing filter lists; when
writing a filter list, write it to a new file, and then rename the new
file on top of the old file, so that you don't lose your old filter list
if, for example, you run out of disk space or disk quota.
svn path=/trunk/; revision=2948
2001-01-28 09:13:10 +00:00
|
|
|
|
2009-05-01 16:36:04 +00:00
|
|
|
case CFILTER_EDITED_LIST:
|
|
|
|
return cfilter_dialogs;
|
Have separate capture and display filter lists; some filter dialog boxes
use the capture filter lists, and others use the display filter list, as
appropriate.
Have separate menu items for editing the capture and display filter
lists.
Have separate "~/.ethereal/cfilters" and "~/.ethereal/dfilters" files
for the two lists; if either of those files isn't found, we try
"~/.ethereal/filters", which means that you will start out with two
identical lists holding all your filters - if certain filters belong
only in one list, you'll have to delete them by hand from the other
list.
Do I/O error checking when reading and writing filter lists; when
writing a filter list, write it to a new file, and then rename the new
file on top of the old file, so that you don't lose your old filter list
if, for example, you run out of disk space or disk quota.
svn path=/trunk/; revision=2948
2001-01-28 09:13:10 +00:00
|
|
|
|
2009-05-01 16:36:04 +00:00
|
|
|
case DFILTER_EDITED_LIST:
|
|
|
|
return dfilter_dialogs;
|
Have separate capture and display filter lists; some filter dialog boxes
use the capture filter lists, and others use the display filter list, as
appropriate.
Have separate menu items for editing the capture and display filter
lists.
Have separate "~/.ethereal/cfilters" and "~/.ethereal/dfilters" files
for the two lists; if either of those files isn't found, we try
"~/.ethereal/filters", which means that you will start out with two
identical lists holding all your filters - if certain filters belong
only in one list, you'll have to delete them by hand from the other
list.
Do I/O error checking when reading and writing filter lists; when
writing a filter list, write it to a new file, and then rename the new
file on top of the old file, so that you don't lose your old filter list
if, for example, you run out of disk space or disk quota.
svn path=/trunk/; revision=2948
2001-01-28 09:13:10 +00:00
|
|
|
|
2009-05-01 16:36:04 +00:00
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
return NULL;
|
|
|
|
}
|
2001-01-21 03:30:24 +00:00
|
|
|
}
|
|
|
|
|
2006-10-01 19:34:03 +00:00
|
|
|
|
2007-01-25 02:54:14 +00:00
|
|
|
static GtkTreeIter *
|
|
|
|
fill_list(GtkWidget *main_w, filter_list_type_t list_type, const gchar *filter_te_str)
|
2006-10-01 19:34:03 +00:00
|
|
|
{
|
|
|
|
GList *fl_entry;
|
|
|
|
filter_def *filt;
|
2007-01-25 02:54:14 +00:00
|
|
|
GtkTreeView *filter_l;
|
|
|
|
GtkListStore *store;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreeIter *l_select = NULL;
|
2006-10-01 19:34:03 +00:00
|
|
|
|
2008-04-11 16:04:54 +00:00
|
|
|
filter_l = GTK_TREE_VIEW(g_object_get_data(G_OBJECT(main_w), E_FILT_FILTER_L_KEY));
|
2006-10-01 19:34:03 +00:00
|
|
|
store = GTK_LIST_STORE(gtk_tree_view_get_model(filter_l));
|
|
|
|
|
|
|
|
/* fill in data */
|
|
|
|
fl_entry = get_filter_list_first(list_type);
|
|
|
|
while (fl_entry != NULL) {
|
|
|
|
filt = (filter_def *) fl_entry->data;
|
|
|
|
gtk_list_store_append(store, &iter);
|
|
|
|
gtk_list_store_set(store, &iter, 0, filt->name,
|
2009-05-01 16:36:04 +00:00
|
|
|
1, fl_entry, -1);
|
2006-10-01 19:34:03 +00:00
|
|
|
|
|
|
|
if (filter_te_str && filt->strval) {
|
|
|
|
if (strcmp(filter_te_str, filt->strval) == 0) {
|
2007-01-25 02:54:14 +00:00
|
|
|
/*
|
|
|
|
* XXX - We're assuming that we can just copy a GtkTreeIter
|
|
|
|
* and use it later without any crashes. This may not be a
|
|
|
|
* valid assumption.
|
|
|
|
*/
|
|
|
|
l_select = g_memdup(&iter, sizeof(iter));
|
2006-10-01 19:34:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fl_entry = fl_entry->next;
|
|
|
|
}
|
2007-01-25 02:54:14 +00:00
|
|
|
return l_select;
|
2006-10-01 19:34:03 +00:00
|
|
|
}
|
|
|
|
|
2006-10-02 20:59:38 +00:00
|
|
|
#if 0
|
2006-10-01 19:34:03 +00:00
|
|
|
static void
|
|
|
|
clear_list(GtkWidget *main_w) {
|
2008-04-11 16:04:54 +00:00
|
|
|
GtkWidget *filter_l = g_object_get_data(G_OBJECT(main_w), E_FILT_FILTER_L_KEY);
|
2006-10-01 19:34:03 +00:00
|
|
|
GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(filter_l));
|
|
|
|
|
|
|
|
gtk_list_store_clear(GTK_LIST_STORE(model));
|
|
|
|
}
|
2006-10-02 20:59:38 +00:00
|
|
|
#endif /* 0 */
|
2006-10-01 19:34:03 +00:00
|
|
|
|
Split "filter_dialog_cb()" into "filter_dialog_cb()", which pops up a
"global" dialog box when "Edit:Filters" is selected, so that the list of
filters can be edited, and "filter_browse_cb()", which pops up a dialog
box associated with a "Filter:" button and a text entry widget attached
to that button, so that a filter can be selected or saved (although it
also supports the same editing that the "global" dialog box does).
Have "filter_dialog_cb()" connect the window in which the "Filter:"
button lives and the filter dialog box, so that:
if the window in which the "Filter:" button lives goes away, so
does the filter dialog box (as it no longer has a text widget
into which it can stuff the selected filter);
if the "Filter:" button is clicked when there's already a filter
dialog box open, we just reactivate that existing dialog box
rather than popping up a new one.
Also keep a pointer to the "global" filter dialog box, so that we also
arrange that there's only one of them (by reactivating the existing on
if "Edit:Filters" is selected when there's already a "global" filter
dialog box open).
Keep around pointers to the dialog boxes that contain the "Filter:"
buttons, so that we can arrange that there be only one of them (that was
a side-effect of an earlier attempt at fixing the problems described
above, but it's still useful for keeping multiple competing dialog boxes
from being open - there's more of that to be done).
Make the pointer to the "Open Capture File" dialog box widget static to
"file_dlg.c" - nobody outside of "file_dlg.c cares about it.
svn path=/trunk/; revision=1774
2000-04-01 12:03:42 +00:00
|
|
|
static GtkWidget *
|
2003-01-15 05:58:50 +00:00
|
|
|
filter_dialog_new(GtkWidget *button, GtkWidget *parent_filter_te,
|
2006-10-01 17:59:30 +00:00
|
|
|
filter_list_type_t list_type, construct_args_t *construct_args)
|
1999-12-10 06:28:24 +00:00
|
|
|
{
|
2002-11-03 17:38:45 +00:00
|
|
|
GtkWidget *main_w, /* main window */
|
|
|
|
*main_vb, /* main container */
|
|
|
|
*bbox, /* button container */
|
|
|
|
*ok_bt, /* "OK" button */
|
|
|
|
*apply_bt, /* "Apply" button */
|
|
|
|
*save_bt, /* "Save" button */
|
2006-10-01 17:59:30 +00:00
|
|
|
*cancel_bt, /* "Cancel" button */
|
2004-01-25 21:27:16 +00:00
|
|
|
*help_bt; /* "Help" button */
|
2004-01-21 05:35:42 +00:00
|
|
|
GtkWidget *filter_vb, /* filter settings box */
|
|
|
|
*props_vb;
|
2002-11-03 17:38:45 +00:00
|
|
|
GtkWidget *top_hb,
|
|
|
|
*list_bb,
|
|
|
|
*new_bt,
|
|
|
|
*del_bt,
|
|
|
|
*filter_sc,
|
|
|
|
*filter_l,
|
|
|
|
*middle_hb,
|
|
|
|
*name_lb,
|
|
|
|
*name_te,
|
|
|
|
*bottom_hb,
|
|
|
|
*filter_lb,
|
|
|
|
*filter_te,
|
2004-01-21 05:35:42 +00:00
|
|
|
*add_expression_bt,
|
|
|
|
*filter_fr,
|
|
|
|
*edit_fr,
|
|
|
|
*props_fr;
|
2007-06-17 00:54:58 +00:00
|
|
|
GdkWindow *parent;
|
2004-01-25 13:47:09 +00:00
|
|
|
GtkTooltips *tooltips;
|
2006-10-01 17:59:30 +00:00
|
|
|
static filter_list_type_t cfilter_list_type = CFILTER_EDITED_LIST;
|
|
|
|
static filter_list_type_t dfilter_list_type = DFILTER_EDITED_LIST;
|
2004-01-25 12:25:57 +00:00
|
|
|
filter_list_type_t *filter_list_type_p;
|
|
|
|
GList **filter_dialogs;
|
|
|
|
const gchar *filter_te_str = NULL;
|
2002-11-03 17:38:45 +00:00
|
|
|
GtkListStore *store;
|
|
|
|
GtkCellRenderer *renderer;
|
|
|
|
GtkTreeViewColumn *column;
|
|
|
|
GtkTreeSelection *sel;
|
2007-01-25 02:54:14 +00:00
|
|
|
GtkTreeIter *l_select;
|
2008-10-30 13:19:07 +00:00
|
|
|
gchar *list_name = NULL;
|
Have separate capture and display filter lists; some filter dialog boxes
use the capture filter lists, and others use the display filter list, as
appropriate.
Have separate menu items for editing the capture and display filter
lists.
Have separate "~/.ethereal/cfilters" and "~/.ethereal/dfilters" files
for the two lists; if either of those files isn't found, we try
"~/.ethereal/filters", which means that you will start out with two
identical lists holding all your filters - if certain filters belong
only in one list, you'll have to delete them by hand from the other
list.
Do I/O error checking when reading and writing filter lists; when
writing a filter list, write it to a new file, and then rename the new
file on top of the old file, so that you don't lose your old filter list
if, for example, you run out of disk space or disk quota.
svn path=/trunk/; revision=2948
2001-01-28 09:13:10 +00:00
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
/* Get a pointer to a static variable holding the type of filter on
|
|
|
|
which we're working, so we can pass that pointer to callback
|
|
|
|
routines. */
|
2006-10-01 17:59:30 +00:00
|
|
|
switch (list_type) {
|
2002-11-03 17:38:45 +00:00
|
|
|
|
|
|
|
case CFILTER_LIST:
|
|
|
|
filter_dialogs = &cfilter_dialogs;
|
2004-01-25 12:25:57 +00:00
|
|
|
filter_list_type_p = &cfilter_list_type;
|
2006-10-01 17:59:30 +00:00
|
|
|
list_type = CFILTER_EDITED_LIST;
|
2008-10-30 13:19:07 +00:00
|
|
|
list_name = "Capture Filter";
|
2002-11-03 17:38:45 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DFILTER_LIST:
|
|
|
|
filter_dialogs = &dfilter_dialogs;
|
2004-01-25 12:25:57 +00:00
|
|
|
filter_list_type_p = &dfilter_list_type;
|
2006-10-01 17:59:30 +00:00
|
|
|
list_type = DFILTER_EDITED_LIST;
|
2008-10-30 13:19:07 +00:00
|
|
|
list_name = "Display Filter";
|
2002-11-03 17:38:45 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
filter_dialogs = NULL;
|
2004-01-25 12:25:57 +00:00
|
|
|
filter_list_type_p = NULL;
|
2002-11-03 17:38:45 +00:00
|
|
|
break;
|
|
|
|
}
|
Have separate capture and display filter lists; some filter dialog boxes
use the capture filter lists, and others use the display filter list, as
appropriate.
Have separate menu items for editing the capture and display filter
lists.
Have separate "~/.ethereal/cfilters" and "~/.ethereal/dfilters" files
for the two lists; if either of those files isn't found, we try
"~/.ethereal/filters", which means that you will start out with two
identical lists holding all your filters - if certain filters belong
only in one list, you'll have to delete them by hand from the other
list.
Do I/O error checking when reading and writing filter lists; when
writing a filter list, write it to a new file, and then rename the new
file on top of the old file, so that you don't lose your old filter list
if, for example, you run out of disk space or disk quota.
svn path=/trunk/; revision=2948
2001-01-28 09:13:10 +00:00
|
|
|
|
2004-01-25 13:47:09 +00:00
|
|
|
tooltips = gtk_tooltips_new ();
|
|
|
|
|
2008-04-14 15:01:34 +00:00
|
|
|
main_w = dlg_conf_window_new(construct_args->title);
|
2008-04-11 16:04:54 +00:00
|
|
|
gtk_window_set_default_size(GTK_WINDOW(main_w), 400, 400);
|
|
|
|
g_object_set_data(G_OBJECT(main_w), E_FILT_CONSTRUCT_ARGS_KEY, construct_args);
|
2002-11-03 17:38:45 +00:00
|
|
|
|
2003-03-02 13:46:01 +00:00
|
|
|
main_vb = gtk_vbox_new(FALSE, 0);
|
2008-06-29 15:51:43 +00:00
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(main_vb), 5);
|
2002-11-03 17:38:45 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(main_w), main_vb);
|
|
|
|
gtk_widget_show(main_vb);
|
|
|
|
|
|
|
|
/* Make sure everything is set up */
|
|
|
|
if (parent_filter_te)
|
|
|
|
filter_te_str = gtk_entry_get_text(GTK_ENTRY(parent_filter_te));
|
|
|
|
|
|
|
|
/* Container for each row of widgets */
|
2004-01-25 12:25:57 +00:00
|
|
|
filter_vb = gtk_vbox_new(FALSE, 0);
|
2008-06-29 15:51:43 +00:00
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(filter_vb), 0);
|
2004-01-21 05:35:42 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(main_vb), filter_vb);
|
|
|
|
gtk_widget_show(filter_vb);
|
2002-11-03 17:38:45 +00:00
|
|
|
|
2004-01-25 12:25:57 +00:00
|
|
|
/* Top row: Buttons and filter list */
|
|
|
|
top_hb = gtk_hbox_new(FALSE, 0);
|
2004-01-21 05:35:42 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(filter_vb), top_hb);
|
2002-11-03 17:38:45 +00:00
|
|
|
gtk_widget_show(top_hb);
|
|
|
|
|
2004-01-21 05:35:42 +00:00
|
|
|
edit_fr = gtk_frame_new("Edit");
|
|
|
|
gtk_box_pack_start(GTK_BOX(top_hb), edit_fr, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show(edit_fr);
|
|
|
|
|
2004-01-25 12:25:57 +00:00
|
|
|
list_bb = gtk_vbox_new(TRUE, 0);
|
2008-06-29 15:51:43 +00:00
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(list_bb), 5);
|
2004-01-21 05:35:42 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(edit_fr), list_bb);
|
2002-11-03 17:38:45 +00:00
|
|
|
gtk_widget_show(list_bb);
|
|
|
|
|
2008-04-11 18:58:19 +00:00
|
|
|
new_bt = gtk_button_new_from_stock(GTK_STOCK_NEW);
|
2008-04-11 22:10:36 +00:00
|
|
|
g_signal_connect(new_bt, "clicked", G_CALLBACK(filter_new_bt_clicked_cb), filter_list_type_p);
|
2002-11-03 17:38:45 +00:00
|
|
|
gtk_widget_show(new_bt);
|
2004-01-25 12:25:57 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (list_bb), new_bt, FALSE, FALSE, 0);
|
2007-01-25 02:54:14 +00:00
|
|
|
gtk_tooltips_set_tip (tooltips, new_bt,
|
2004-01-25 13:47:09 +00:00
|
|
|
"Create a new filter at the end of the list (with the current properties)", NULL);
|
2002-11-03 17:38:45 +00:00
|
|
|
|
2008-04-11 18:58:19 +00:00
|
|
|
del_bt = gtk_button_new_from_stock(GTK_STOCK_DELETE);
|
2002-11-11 15:39:06 +00:00
|
|
|
gtk_widget_set_sensitive(del_bt, FALSE);
|
2008-04-11 22:10:36 +00:00
|
|
|
g_signal_connect(del_bt, "clicked", G_CALLBACK(filter_del_bt_clicked_cb), filter_list_type_p);
|
2008-04-11 16:04:54 +00:00
|
|
|
g_object_set_data(G_OBJECT(main_w), E_FILT_DEL_BT_KEY, del_bt);
|
2002-11-03 17:38:45 +00:00
|
|
|
gtk_widget_show(del_bt);
|
2004-01-25 12:25:57 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (list_bb), del_bt, FALSE, FALSE, 0);
|
2004-01-25 13:47:09 +00:00
|
|
|
gtk_tooltips_set_tip (tooltips, del_bt, ("Delete the selected filter"), NULL);
|
2002-11-03 17:38:45 +00:00
|
|
|
|
2008-10-30 13:19:07 +00:00
|
|
|
filter_fr = gtk_frame_new(list_name);
|
2004-01-21 05:35:42 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(top_hb), filter_fr, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show(filter_fr);
|
1999-12-10 06:28:24 +00:00
|
|
|
|
2004-02-06 19:19:12 +00:00
|
|
|
filter_sc = scrolled_window_new(NULL, NULL);
|
2007-01-25 02:54:14 +00:00
|
|
|
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(filter_sc),
|
2004-02-06 19:19:12 +00:00
|
|
|
GTK_SHADOW_IN);
|
|
|
|
|
2004-01-21 05:35:42 +00:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (filter_sc), 5);
|
|
|
|
gtk_container_add(GTK_CONTAINER(filter_fr), filter_sc);
|
2002-11-03 17:38:45 +00:00
|
|
|
gtk_widget_show(filter_sc);
|
|
|
|
|
|
|
|
store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_POINTER);
|
|
|
|
filter_l = tree_view_new(GTK_TREE_MODEL(store));
|
|
|
|
gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(filter_l), FALSE);
|
|
|
|
renderer = gtk_cell_renderer_text_new();
|
|
|
|
column = gtk_tree_view_column_new_with_attributes("", renderer, "text",
|
|
|
|
0, NULL);
|
|
|
|
gtk_tree_view_column_set_sort_column_id(column, 0);
|
|
|
|
gtk_tree_view_append_column(GTK_TREE_VIEW(filter_l), column);
|
|
|
|
sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(filter_l));
|
|
|
|
gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE);
|
2008-04-11 22:10:36 +00:00
|
|
|
g_signal_connect(sel, "changed", G_CALLBACK(filter_sel_list_cb), filter_vb);
|
|
|
|
g_signal_connect(filter_l, "button_press_event", G_CALLBACK(filter_sel_list_button_cb),
|
2002-11-11 15:39:06 +00:00
|
|
|
NULL);
|
2008-04-11 16:04:54 +00:00
|
|
|
g_object_set_data(G_OBJECT(main_w), E_FILT_FILTER_L_KEY, filter_l);
|
2002-11-03 17:38:45 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(filter_sc), filter_l);
|
|
|
|
gtk_widget_show(filter_l);
|
|
|
|
|
2008-04-11 16:04:54 +00:00
|
|
|
g_object_set_data(G_OBJECT(filter_l), E_FILT_DBLFUNC_KEY, filter_dlg_dclick);
|
|
|
|
g_object_set_data(G_OBJECT(filter_l), E_FILT_DBLARG_KEY, main_w);
|
2002-11-03 17:38:45 +00:00
|
|
|
/* This is a Boolean, but we make it a non-null pointer for TRUE
|
|
|
|
and a null pointer for FALSE, as object data is a pointer. */
|
2008-04-11 16:04:54 +00:00
|
|
|
g_object_set_data(G_OBJECT(filter_l), E_FILT_DBLACTIVATE_KEY,
|
2002-11-11 15:39:06 +00:00
|
|
|
construct_args->activate_on_ok ? "" : NULL);
|
2001-01-02 01:32:21 +00:00
|
|
|
|
2004-01-25 12:25:57 +00:00
|
|
|
/* fill in data */
|
2007-01-25 02:54:14 +00:00
|
|
|
l_select = fill_list(main_w, list_type, filter_te_str);
|
2002-11-03 17:38:45 +00:00
|
|
|
|
|
|
|
g_object_unref(G_OBJECT(store));
|
2001-01-02 01:32:21 +00:00
|
|
|
|
2004-01-21 05:35:42 +00:00
|
|
|
|
|
|
|
props_fr = gtk_frame_new("Properties");
|
|
|
|
gtk_box_pack_start(GTK_BOX(filter_vb), props_fr, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show(props_fr);
|
|
|
|
|
2004-01-25 12:25:57 +00:00
|
|
|
props_vb = gtk_vbox_new(FALSE, 3);
|
2008-06-29 15:51:43 +00:00
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(props_vb), 5);
|
2004-01-21 05:35:42 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(props_fr), props_vb);
|
|
|
|
gtk_widget_show(props_vb);
|
|
|
|
|
2004-01-25 12:25:57 +00:00
|
|
|
/* row: Filter name entry */
|
|
|
|
middle_hb = gtk_hbox_new(FALSE, 3);
|
2004-01-21 05:35:42 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(props_vb), middle_hb);
|
2002-11-03 17:38:45 +00:00
|
|
|
gtk_widget_show(middle_hb);
|
|
|
|
|
|
|
|
name_lb = gtk_label_new("Filter name:");
|
2004-01-25 12:25:57 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(middle_hb), name_lb, FALSE, FALSE, 0);
|
2002-11-03 17:38:45 +00:00
|
|
|
gtk_widget_show(name_lb);
|
|
|
|
|
|
|
|
name_te = gtk_entry_new();
|
2004-01-25 12:25:57 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(middle_hb), name_te, TRUE, TRUE, 0);
|
2008-04-11 16:04:54 +00:00
|
|
|
g_object_set_data(G_OBJECT(main_w), E_FILT_NAME_TE_KEY, name_te);
|
2008-04-11 22:10:36 +00:00
|
|
|
g_signal_connect(name_te, "changed", G_CALLBACK(filter_name_te_changed_cb), filter_list_type_p);
|
2002-11-03 17:38:45 +00:00
|
|
|
gtk_widget_show(name_te);
|
1999-12-10 06:28:24 +00:00
|
|
|
|
2004-01-25 12:25:57 +00:00
|
|
|
/* row: Filter text entry */
|
|
|
|
bottom_hb = gtk_hbox_new(FALSE, 3);
|
2004-01-21 05:35:42 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(props_vb), bottom_hb);
|
2002-11-03 17:38:45 +00:00
|
|
|
gtk_widget_show(bottom_hb);
|
1999-12-10 06:28:24 +00:00
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
filter_lb = gtk_label_new("Filter string:");
|
2004-01-25 12:25:57 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(bottom_hb), filter_lb, FALSE, FALSE, 0);
|
2002-11-03 17:38:45 +00:00
|
|
|
gtk_widget_show(filter_lb);
|
1999-12-10 06:28:24 +00:00
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
filter_te = gtk_entry_new();
|
2004-01-25 12:25:57 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(bottom_hb), filter_te, TRUE, TRUE, 0);
|
2008-04-11 16:04:54 +00:00
|
|
|
g_object_set_data(G_OBJECT(main_w), E_FILT_FILTER_TE_KEY, filter_te);
|
2008-04-11 22:10:36 +00:00
|
|
|
g_signal_connect(filter_te, "changed", G_CALLBACK(filter_name_te_changed_cb), filter_list_type_p);
|
2008-10-11 15:50:29 +00:00
|
|
|
if (list_type == DFILTER_EDITED_LIST) {
|
|
|
|
colorize_filter_te_as_empty(filter_te);
|
2008-10-26 21:53:24 +00:00
|
|
|
|
2009-05-01 16:36:04 +00:00
|
|
|
g_object_set_data(G_OBJECT(main_w), E_FILT_AUTOCOMP_PTR_KEY, NULL);
|
|
|
|
g_signal_connect(filter_te, "key-press-event", G_CALLBACK (filter_string_te_key_pressed_cb), NULL);
|
|
|
|
g_signal_connect(main_w, "key-press-event", G_CALLBACK (filter_parent_dlg_key_pressed_cb), NULL);
|
2008-10-11 15:50:29 +00:00
|
|
|
}
|
2002-11-03 17:38:45 +00:00
|
|
|
gtk_widget_show(filter_te);
|
|
|
|
|
2008-04-11 16:04:54 +00:00
|
|
|
g_object_set_data(G_OBJECT(main_w), E_FILT_PARENT_FILTER_TE_KEY, parent_filter_te);
|
2002-11-03 17:38:45 +00:00
|
|
|
|
2006-10-01 17:59:30 +00:00
|
|
|
if (list_type == DFILTER_EDITED_LIST) {
|
2007-01-25 02:54:14 +00:00
|
|
|
gtk_tooltips_set_tip(tooltips, filter_te,
|
2004-01-26 18:51:04 +00:00
|
|
|
"Enter a display filter. "
|
2009-05-01 16:36:04 +00:00
|
|
|
"The background color of this field is changed by a continuous syntax check"
|
|
|
|
" (green is valid, red is invalid, yellow may have unexpected results).",
|
2004-01-26 18:51:04 +00:00
|
|
|
NULL);
|
|
|
|
|
2004-01-21 05:35:42 +00:00
|
|
|
/* Create the "Add Expression..." button, to pop up a dialog
|
|
|
|
for constructing filter comparison expressions. */
|
2008-04-11 18:58:19 +00:00
|
|
|
add_expression_bt = gtk_button_new_from_stock(WIRESHARK_STOCK_ADD_EXPRESSION);
|
2008-04-11 22:10:36 +00:00
|
|
|
g_signal_connect(add_expression_bt, "clicked", G_CALLBACK(filter_add_expr_bt_cb), main_w);
|
2004-01-25 12:25:57 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(bottom_hb), add_expression_bt, FALSE, FALSE, 0);
|
2004-01-21 05:35:42 +00:00
|
|
|
gtk_widget_show(add_expression_bt);
|
2004-01-25 13:47:09 +00:00
|
|
|
gtk_tooltips_set_tip (tooltips, add_expression_bt, ("Add an expression to the filter string"), NULL);
|
2004-01-21 05:35:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-03 19:53:10 +00:00
|
|
|
/* button row (create all possible buttons and hide the unrequired later - it's a lot easier) */
|
|
|
|
bbox = dlg_button_row_new(GTK_STOCK_OK, GTK_STOCK_APPLY, GTK_STOCK_SAVE, GTK_STOCK_CANCEL, GTK_STOCK_HELP, NULL);
|
2004-01-25 12:25:57 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 5);
|
2002-11-03 17:38:45 +00:00
|
|
|
gtk_widget_show(bbox);
|
|
|
|
|
2008-04-11 16:04:54 +00:00
|
|
|
ok_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_OK);
|
2008-04-11 22:10:36 +00:00
|
|
|
g_signal_connect(ok_bt, "clicked", G_CALLBACK(filter_dlg_ok_cb), filter_list_type_p);
|
2006-10-03 19:53:10 +00:00
|
|
|
gtk_tooltips_set_tip (tooltips, ok_bt, ("Apply the filters and close this dialog"), NULL);
|
|
|
|
|
|
|
|
/* Catch the "activate" signal on the filter name and filter
|
|
|
|
expression text entries, so that if the user types Return
|
|
|
|
there, we act as if the "OK" button had been selected, as
|
|
|
|
happens if Return is typed if some widget that *doesn't*
|
|
|
|
handle the Return key has the input focus. */
|
2002-11-03 17:38:45 +00:00
|
|
|
if (parent_filter_te != NULL) {
|
|
|
|
dlg_set_activate(name_te, ok_bt);
|
|
|
|
dlg_set_activate(filter_te, ok_bt);
|
|
|
|
}
|
2000-10-25 16:06:50 +00:00
|
|
|
|
2008-04-11 16:04:54 +00:00
|
|
|
apply_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_APPLY);
|
2008-04-11 22:10:36 +00:00
|
|
|
g_signal_connect(apply_bt, "clicked", G_CALLBACK(filter_dlg_apply_cb), filter_list_type_p);
|
2006-10-03 19:53:10 +00:00
|
|
|
gtk_tooltips_set_tip (tooltips, apply_bt, ("Apply the filters and keep this dialog open"), NULL);
|
2001-01-21 03:30:24 +00:00
|
|
|
|
2008-04-11 16:04:54 +00:00
|
|
|
save_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_SAVE);
|
2008-04-11 22:10:36 +00:00
|
|
|
g_signal_connect(save_bt, "clicked", G_CALLBACK(filter_dlg_save_cb), filter_list_type_p);
|
2004-01-25 13:47:09 +00:00
|
|
|
gtk_tooltips_set_tip (tooltips, save_bt, ("Save the filters permanently and keep this dialog open"), NULL);
|
2002-11-03 17:38:45 +00:00
|
|
|
|
2008-04-11 16:04:54 +00:00
|
|
|
cancel_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CANCEL);
|
2006-10-01 17:59:30 +00:00
|
|
|
gtk_tooltips_set_tip (tooltips, cancel_bt, ("Cancel the changes"), NULL);
|
2008-04-11 22:10:36 +00:00
|
|
|
g_signal_connect(cancel_bt, "clicked", G_CALLBACK(filter_dlg_cancel_cb), filter_list_type_p);
|
2007-09-03 00:17:47 +00:00
|
|
|
window_set_cancel_button(main_w, cancel_bt, NULL);
|
Split "filter_dialog_cb()" into "filter_dialog_cb()", which pops up a
"global" dialog box when "Edit:Filters" is selected, so that the list of
filters can be edited, and "filter_browse_cb()", which pops up a dialog
box associated with a "Filter:" button and a text entry widget attached
to that button, so that a filter can be selected or saved (although it
also supports the same editing that the "global" dialog box does).
Have "filter_dialog_cb()" connect the window in which the "Filter:"
button lives and the filter dialog box, so that:
if the window in which the "Filter:" button lives goes away, so
does the filter dialog box (as it no longer has a text widget
into which it can stuff the selected filter);
if the "Filter:" button is clicked when there's already a filter
dialog box open, we just reactivate that existing dialog box
rather than popping up a new one.
Also keep a pointer to the "global" filter dialog box, so that we also
arrange that there's only one of them (by reactivating the existing on
if "Edit:Filters" is selected when there's already a "global" filter
dialog box open).
Keep around pointers to the dialog boxes that contain the "Filter:"
buttons, so that we can arrange that there be only one of them (that was
a side-effect of an earlier attempt at fixing the problems described
above, but it's still useful for keeping multiple competing dialog boxes
from being open - there's more of that to be done).
Make the pointer to the "Open Capture File" dialog box widget static to
"file_dlg.c" - nobody outside of "file_dlg.c cares about it.
svn path=/trunk/; revision=1774
2000-04-01 12:03:42 +00:00
|
|
|
|
2008-04-11 16:04:54 +00:00
|
|
|
help_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_HELP);
|
2006-10-01 17:59:30 +00:00
|
|
|
if (list_type == CFILTER_EDITED_LIST) {
|
2008-04-11 22:10:36 +00:00
|
|
|
g_signal_connect(help_bt, "clicked", G_CALLBACK(topic_cb), (gpointer)HELP_CAPTURE_FILTERS_DIALOG);
|
2004-01-25 21:27:16 +00:00
|
|
|
} else {
|
2008-04-11 22:10:36 +00:00
|
|
|
g_signal_connect(help_bt, "clicked", G_CALLBACK(topic_cb), (gpointer)HELP_DISPLAY_FILTERS_DIALOG);
|
2004-01-25 21:27:16 +00:00
|
|
|
}
|
|
|
|
gtk_tooltips_set_tip (tooltips, help_bt, ("Show topic specific help"), NULL);
|
|
|
|
|
2004-05-26 03:49:24 +00:00
|
|
|
if(ok_bt) {
|
|
|
|
gtk_widget_grab_default(ok_bt);
|
|
|
|
}
|
2002-11-03 17:38:45 +00:00
|
|
|
|
|
|
|
remember_filter_dialog(main_w, filter_dialogs);
|
|
|
|
|
2003-01-15 05:58:50 +00:00
|
|
|
if (button != NULL) {
|
2009-05-01 16:36:04 +00:00
|
|
|
/* This dialog box was created by a "Filter" button.
|
|
|
|
Set the E_FILT_BUTTON_PTR_KEY for the new dialog to point to
|
|
|
|
the button. */
|
|
|
|
g_object_set_data(G_OBJECT(main_w), E_FILT_BUTTON_PTR_KEY, button);
|
2003-01-15 05:58:50 +00:00
|
|
|
|
2009-05-01 16:36:04 +00:00
|
|
|
/* Set the E_FILT_DIALOG_PTR_KEY for the button to point to us */
|
|
|
|
g_object_set_data(G_OBJECT(button), E_FILT_DIALOG_PTR_KEY, main_w);
|
2003-01-15 05:58:50 +00:00
|
|
|
}
|
|
|
|
|
2004-01-25 12:25:57 +00:00
|
|
|
/* DO SELECTION THINGS *AFTER* SHOWING THE DIALOG! */
|
|
|
|
/* otherwise the updatings can get confused */
|
|
|
|
if (l_select) {
|
2007-01-25 02:54:14 +00:00
|
|
|
gtk_tree_selection_select_iter(sel, l_select);
|
|
|
|
g_free(l_select);
|
2004-01-25 12:25:57 +00:00
|
|
|
} else if (filter_te_str && filter_te_str[0]) {
|
|
|
|
gtk_entry_set_text(GTK_ENTRY(name_te), "New filter");
|
|
|
|
gtk_entry_set_text(GTK_ENTRY(filter_te), filter_te_str);
|
|
|
|
}
|
|
|
|
|
2008-04-11 22:10:36 +00:00
|
|
|
g_signal_connect(main_w, "delete_event", G_CALLBACK(filter_dlg_delete_event_cb), filter_list_type_p);
|
|
|
|
g_signal_connect(main_w, "destroy", G_CALLBACK(filter_dlg_destroy_cb), filter_list_type_p);
|
2006-10-01 17:59:30 +00:00
|
|
|
|
2004-05-26 03:49:24 +00:00
|
|
|
gtk_widget_show(main_w);
|
2006-10-03 19:53:10 +00:00
|
|
|
|
2007-06-17 00:54:58 +00:00
|
|
|
if(construct_args->modal_and_transient) {
|
|
|
|
parent = gtk_widget_get_parent_window(parent_filter_te);
|
|
|
|
gdk_window_set_transient_for(main_w->window, parent);
|
|
|
|
gtk_window_set_modal(GTK_WINDOW(main_w), TRUE);
|
|
|
|
}
|
|
|
|
|
2006-10-03 19:53:10 +00:00
|
|
|
/* hide the Ok button, if we don't have to apply it and our caller wants a Save button */
|
|
|
|
if (parent_filter_te == NULL && prefs.gui_use_pref_save) {
|
|
|
|
gtk_widget_hide(ok_bt);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* hide the Apply button, if our caller don't wants one */
|
|
|
|
if (!construct_args->wants_apply_button) {
|
|
|
|
gtk_widget_hide(apply_bt);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* hide the Save button if the user uses implicit save */
|
|
|
|
if (!prefs.gui_use_pref_save) {
|
|
|
|
gtk_widget_hide(save_bt);
|
|
|
|
}
|
|
|
|
|
2004-05-26 03:49:24 +00:00
|
|
|
window_present(main_w);
|
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
return main_w;
|
1999-12-10 06:28:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-03-16 22:02:55 +00:00
|
|
|
filter_dlg_dclick(GtkWidget *filter_l, gpointer main_w_arg, gpointer activate)
|
1999-12-10 06:28:24 +00:00
|
|
|
{
|
2002-11-03 17:38:45 +00:00
|
|
|
GtkWidget *main_w = GTK_WIDGET(main_w_arg);
|
|
|
|
GtkWidget *parent_filter_te =
|
2008-04-11 16:04:54 +00:00
|
|
|
g_object_get_data(G_OBJECT(main_w), E_FILT_PARENT_FILTER_TE_KEY);
|
2002-11-03 17:38:45 +00:00
|
|
|
GList *flp;
|
|
|
|
filter_def *filt;
|
|
|
|
GtkTreeSelection *sel;
|
|
|
|
GtkTreeModel *model;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
|
|
|
sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(filter_l));
|
2001-01-02 01:32:21 +00:00
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
if (parent_filter_te != NULL) {
|
|
|
|
/*
|
|
|
|
* We have a text entry widget associated with this dialog
|
|
|
|
* box; is one of the filters in the list selected?
|
|
|
|
*/
|
|
|
|
if (gtk_tree_selection_get_selected(sel, &model, &iter)) {
|
|
|
|
/*
|
|
|
|
* Yes. Is there a filter definition for that filter?
|
|
|
|
*/
|
|
|
|
gtk_tree_model_get(model, &iter, 1, &flp, -1);
|
|
|
|
if (flp) {
|
|
|
|
/*
|
|
|
|
* Yes - put it in the text entry widget.
|
|
|
|
*/
|
|
|
|
filt = (filter_def *) flp->data;
|
|
|
|
gtk_entry_set_text(GTK_ENTRY(parent_filter_te),
|
|
|
|
filt->strval);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Are we supposed to cause the filter we
|
|
|
|
* put there to be applied?
|
|
|
|
*/
|
|
|
|
if (activate != NULL) {
|
|
|
|
/*
|
|
|
|
* Yes - do so.
|
|
|
|
*/
|
2008-04-11 05:03:33 +00:00
|
|
|
g_signal_emit_by_name(G_OBJECT(parent_filter_te), "activate", NULL);
|
2002-11-03 17:38:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-01-02 01:32:21 +00:00
|
|
|
|
2004-05-26 03:49:24 +00:00
|
|
|
window_destroy(main_w);
|
1999-12-10 06:28:24 +00:00
|
|
|
}
|
1998-09-16 02:39:15 +00:00
|
|
|
|
1999-12-10 06:28:24 +00:00
|
|
|
static void
|
2006-10-03 19:53:10 +00:00
|
|
|
filter_dlg_ok_cb(GtkWidget *ok_bt, gpointer data)
|
2001-01-02 01:32:21 +00:00
|
|
|
{
|
2009-05-01 16:36:04 +00:00
|
|
|
filter_list_type_t list_type = *(filter_list_type_t *)data;
|
2006-10-03 19:53:10 +00:00
|
|
|
|
2009-05-01 16:36:04 +00:00
|
|
|
/*
|
|
|
|
* Destroy the dialog box and apply the filter.
|
|
|
|
*/
|
|
|
|
filter_apply(gtk_widget_get_toplevel(ok_bt), TRUE);
|
2006-10-03 19:53:10 +00:00
|
|
|
|
2009-05-01 16:36:04 +00:00
|
|
|
/* if we don't have a Save button, just save the settings now */
|
|
|
|
if (!prefs.gui_use_pref_save) {
|
|
|
|
filter_dlg_save(list_type);
|
|
|
|
}
|
2001-01-02 01:32:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-10-03 21:03:08 +00:00
|
|
|
filter_dlg_apply_cb(GtkWidget *apply_bt, gpointer data)
|
2001-01-02 01:32:21 +00:00
|
|
|
{
|
2009-05-01 16:36:04 +00:00
|
|
|
filter_list_type_t list_type = *(filter_list_type_t *)data;
|
2006-10-03 21:03:08 +00:00
|
|
|
|
2009-05-01 16:36:04 +00:00
|
|
|
/*
|
|
|
|
* Apply the filter, but don't destroy the dialog box.
|
|
|
|
*/
|
|
|
|
filter_apply(gtk_widget_get_toplevel(apply_bt), FALSE);
|
2006-10-03 21:03:08 +00:00
|
|
|
|
2009-05-01 16:36:04 +00:00
|
|
|
/* if we don't have a Save button, just save the settings now */
|
|
|
|
if (!prefs.gui_use_pref_save) {
|
|
|
|
filter_dlg_save(list_type);
|
|
|
|
}
|
In the process of destroying a filter editing dialog box, we get a
selection change event on the list of filters. Unfortunately, this can
happen after some other widgets in that dialog box have already been
destroyed - including some of the widgets that such a selection change
event can change.
This sometimes happened when "filter_prefs_delete()" hadn't been called,
so the mechanism we had been using, with a Boolean datum attached to the
dialog box, set in "filter_prefs_delete()" before we actually destroy
the dialog box, wasn't sufficient to keep that from happening.
Attach to the top-level window data items containing pointers to the
widgets changed when a filter is selected from the list, give each of
those widgets their own destroy callbacks, clear the pointer attached to
the top-level widget when the widget is destroyed, and don't do anything
to the widget when a filter is selected from the list if the pointer for
that widget is null, as that means the widget's been destroyed and we
*can't* do anything to it.
Not all filter editing dialogs created on behalf of a "Filter:" button
next to a text entry box should, when you click "OK", activate the text
entry box; if the text entry box is part of a dialog box with multiple
widgets, the user might not have filled in all of the items in that
dialog box, so you shouldn't activate it for them. Add a mechanism by
which, when creating a filter editing dialog box, you can specify
whether the "OK" button should just fill in the text entry box or should
fill it in and also activate it.
svn path=/trunk/; revision=2922
2001-01-21 01:45:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-05-02 23:49:21 +00:00
|
|
|
filter_apply(GtkWidget *main_w, gboolean destroy)
|
In the process of destroying a filter editing dialog box, we get a
selection change event on the list of filters. Unfortunately, this can
happen after some other widgets in that dialog box have already been
destroyed - including some of the widgets that such a selection change
event can change.
This sometimes happened when "filter_prefs_delete()" hadn't been called,
so the mechanism we had been using, with a Boolean datum attached to the
dialog box, set in "filter_prefs_delete()" before we actually destroy
the dialog box, wasn't sufficient to keep that from happening.
Attach to the top-level window data items containing pointers to the
widgets changed when a filter is selected from the list, give each of
those widgets their own destroy callbacks, clear the pointer attached to
the top-level widget when the widget is destroyed, and don't do anything
to the widget when a filter is selected from the list if the pointer for
that widget is null, as that means the widget's been destroyed and we
*can't* do anything to it.
Not all filter editing dialogs created on behalf of a "Filter:" button
next to a text entry box should, when you click "OK", activate the text
entry box; if the text entry box is part of a dialog box with multiple
widgets, the user might not have filled in all of the items in that
dialog box, so you shouldn't activate it for them. Add a mechanism by
which, when creating a filter editing dialog box, you can specify
whether the "OK" button should just fill in the text entry box or should
fill it in and also activate it.
svn path=/trunk/; revision=2922
2001-01-21 01:45:07 +00:00
|
|
|
{
|
2009-05-01 16:36:04 +00:00
|
|
|
construct_args_t *construct_args =
|
|
|
|
g_object_get_data(G_OBJECT(main_w), E_FILT_CONSTRUCT_ARGS_KEY);
|
|
|
|
GtkWidget *parent_filter_te =
|
|
|
|
g_object_get_data(G_OBJECT(main_w), E_FILT_PARENT_FILTER_TE_KEY);
|
|
|
|
GtkWidget *filter_te;
|
|
|
|
const gchar *filter_string;
|
|
|
|
|
|
|
|
if (parent_filter_te != NULL) {
|
|
|
|
/*
|
|
|
|
* We have a text entry widget associated with this dialog
|
|
|
|
* box; put the filter in our text entry widget into that
|
|
|
|
* text entry widget.
|
|
|
|
*/
|
2008-04-11 16:04:54 +00:00
|
|
|
filter_te = g_object_get_data(G_OBJECT(main_w), E_FILT_FILTER_TE_KEY);
|
2009-05-01 16:36:04 +00:00
|
|
|
filter_string =
|
2002-11-11 15:39:06 +00:00
|
|
|
(const gchar *)gtk_entry_get_text(GTK_ENTRY(filter_te));
|
2009-05-01 16:36:04 +00:00
|
|
|
gtk_entry_set_text(GTK_ENTRY(parent_filter_te), filter_string);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (destroy) {
|
|
|
|
/*
|
|
|
|
* Destroy the filter dialog box.
|
|
|
|
*/
|
|
|
|
window_destroy(main_w);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (parent_filter_te != NULL) {
|
|
|
|
/*
|
|
|
|
* We have a text entry widget associated with this dialog
|
|
|
|
* box; activate that widget to cause the filter we put
|
|
|
|
* there to be applied if we're supposed to do so.
|
|
|
|
*
|
|
|
|
* We do this after dismissing the filter dialog box,
|
|
|
|
* as activating the widget the dialog box to which
|
|
|
|
* it belongs to be dismissed, and that may cause it
|
|
|
|
* to destroy our dialog box if the filter succeeds.
|
|
|
|
* This means that our subsequent attempt to destroy
|
|
|
|
* it will fail.
|
|
|
|
*
|
|
|
|
* We don't know whether it'll destroy our dialog box,
|
|
|
|
* so we can't rely on it to do so. Instead, we
|
|
|
|
* destroy it ourselves, which will clear the
|
|
|
|
* E_FILT_DIALOG_PTR_KEY pointer for their dialog box,
|
|
|
|
* meaning they won't think it has one and won't try
|
|
|
|
* to destroy it.
|
|
|
|
*/
|
|
|
|
if (construct_args->activate_on_ok) {
|
|
|
|
g_signal_emit_by_name(G_OBJECT(parent_filter_te), "activate", NULL);
|
|
|
|
}
|
|
|
|
}
|
2001-01-02 01:32:21 +00:00
|
|
|
}
|
|
|
|
|
2006-10-03 19:53:10 +00:00
|
|
|
|
2001-01-02 01:32:21 +00:00
|
|
|
static void
|
2006-10-03 19:53:10 +00:00
|
|
|
filter_dlg_save(filter_list_type_t list_type)
|
1999-12-10 06:28:24 +00:00
|
|
|
{
|
2009-05-01 16:36:04 +00:00
|
|
|
char *pf_dir_path;
|
|
|
|
char *f_path;
|
|
|
|
int f_save_errno;
|
2006-10-01 17:59:30 +00:00
|
|
|
const char *filter_type;
|
|
|
|
|
2009-05-01 16:36:04 +00:00
|
|
|
switch (list_type) {
|
2006-10-01 17:59:30 +00:00
|
|
|
|
2009-05-01 16:36:04 +00:00
|
|
|
case CFILTER_EDITED_LIST:
|
|
|
|
filter_type = "capture";
|
2006-10-01 17:59:30 +00:00
|
|
|
list_type = CFILTER_LIST;
|
|
|
|
copy_filter_list(CFILTER_LIST, CFILTER_EDITED_LIST);
|
2009-05-01 16:36:04 +00:00
|
|
|
break;
|
2006-10-01 17:59:30 +00:00
|
|
|
|
2009-05-01 16:36:04 +00:00
|
|
|
case DFILTER_EDITED_LIST:
|
|
|
|
filter_type = "display";
|
2006-10-01 17:59:30 +00:00
|
|
|
list_type = DFILTER_LIST;
|
|
|
|
copy_filter_list(DFILTER_LIST, DFILTER_EDITED_LIST);
|
2009-05-01 16:36:04 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
filter_type = NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create the directory that holds personal configuration files,
|
|
|
|
if necessary. */
|
|
|
|
if (create_persconffile_dir(&pf_dir_path) == -1) {
|
|
|
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
|
|
|
"Can't create directory\n\"%s\"\nfor filter files: %s.",
|
|
|
|
pf_dir_path, strerror(errno));
|
|
|
|
g_free(pf_dir_path);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
save_filter_list(list_type, &f_path, &f_save_errno);
|
|
|
|
if (f_path != NULL) {
|
|
|
|
/* We had an error saving the filter. */
|
|
|
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
|
|
|
"Could not save to your %s filter file\n\"%s\": %s.",
|
|
|
|
filter_type, f_path, strerror(f_save_errno));
|
|
|
|
g_free(f_path);
|
|
|
|
}
|
1999-12-10 06:28:24 +00:00
|
|
|
}
|
|
|
|
|
2006-10-03 19:53:10 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
filter_dlg_save_cb(GtkWidget *save_bt _U_, gpointer data)
|
|
|
|
{
|
2009-05-01 16:36:04 +00:00
|
|
|
filter_list_type_t list_type = *(filter_list_type_t *)data;
|
2006-10-03 19:53:10 +00:00
|
|
|
|
2009-05-01 16:36:04 +00:00
|
|
|
filter_dlg_save(list_type);
|
2006-10-03 19:53:10 +00:00
|
|
|
}
|
|
|
|
|
2006-10-02 20:59:38 +00:00
|
|
|
#if 0
|
2006-10-01 19:34:03 +00:00
|
|
|
/* update a remaining dialog if another one was cancelled */
|
|
|
|
static void filter_dlg_update_list_cb(gpointer data, gpointer user_data)
|
|
|
|
{
|
|
|
|
GtkWidget *main_w = data;
|
|
|
|
filter_list_type_t list_type = *(filter_list_type_t *)user_data;
|
|
|
|
|
|
|
|
/* refill the list */
|
|
|
|
clear_list(main_w);
|
2007-01-25 02:54:14 +00:00
|
|
|
fill_list(main_w, list_type, NULL);
|
2006-10-01 19:34:03 +00:00
|
|
|
}
|
2006-10-02 20:59:38 +00:00
|
|
|
#endif
|
2006-10-01 19:34:03 +00:00
|
|
|
|
|
|
|
/* cancel button pressed, revert changes and exit dialog */
|
2006-10-01 17:59:30 +00:00
|
|
|
static void
|
|
|
|
filter_dlg_cancel_cb(GtkWidget *cancel_bt, gpointer data)
|
|
|
|
{
|
|
|
|
filter_list_type_t list_type = *(filter_list_type_t *)data;
|
|
|
|
GtkWidget *main_w = gtk_widget_get_toplevel(cancel_bt);
|
2006-10-02 20:59:38 +00:00
|
|
|
static GList *filter_list;
|
2006-10-01 17:59:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
window_destroy(GTK_WIDGET(main_w));
|
2006-10-01 19:34:03 +00:00
|
|
|
|
2006-10-02 20:59:38 +00:00
|
|
|
/* if this was the last open filter dialog, revert the changes made */
|
|
|
|
filter_list = get_filter_dialog_list(list_type);
|
|
|
|
if(g_list_length(filter_list) == 0) {
|
|
|
|
/* revert changes in the edited list */
|
|
|
|
switch (list_type) {
|
|
|
|
case CFILTER_EDITED_LIST:
|
|
|
|
copy_filter_list(CFILTER_EDITED_LIST, CFILTER_LIST);
|
2009-05-01 16:36:04 +00:00
|
|
|
break;
|
2006-10-02 20:59:38 +00:00
|
|
|
case DFILTER_EDITED_LIST:
|
|
|
|
copy_filter_list(DFILTER_EDITED_LIST, DFILTER_LIST);
|
2009-05-01 16:36:04 +00:00
|
|
|
break;
|
2006-10-02 20:59:38 +00:00
|
|
|
default:
|
2009-05-01 16:36:04 +00:00
|
|
|
g_assert_not_reached();
|
|
|
|
break;
|
2006-10-02 20:59:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
2006-10-01 19:34:03 +00:00
|
|
|
/* update other open filter dialogs */
|
|
|
|
g_list_foreach(get_filter_dialog_list(list_type), filter_dlg_update_list_cb, &list_type);
|
2006-10-02 20:59:38 +00:00
|
|
|
#endif
|
2006-10-01 17:59:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Treat this as a cancel, by calling "filter_dlg_cancel_cb()" */
|
|
|
|
static gboolean
|
|
|
|
filter_dlg_delete_event_cb(GtkWidget *main_w, GdkEvent *event _U_,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2009-05-01 16:36:04 +00:00
|
|
|
filter_dlg_cancel_cb(main_w, data);
|
|
|
|
return FALSE;
|
2006-10-01 17:59:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
Split "filter_dialog_cb()" into "filter_dialog_cb()", which pops up a
"global" dialog box when "Edit:Filters" is selected, so that the list of
filters can be edited, and "filter_browse_cb()", which pops up a dialog
box associated with a "Filter:" button and a text entry widget attached
to that button, so that a filter can be selected or saved (although it
also supports the same editing that the "global" dialog box does).
Have "filter_dialog_cb()" connect the window in which the "Filter:"
button lives and the filter dialog box, so that:
if the window in which the "Filter:" button lives goes away, so
does the filter dialog box (as it no longer has a text widget
into which it can stuff the selected filter);
if the "Filter:" button is clicked when there's already a filter
dialog box open, we just reactivate that existing dialog box
rather than popping up a new one.
Also keep a pointer to the "global" filter dialog box, so that we also
arrange that there's only one of them (by reactivating the existing on
if "Edit:Filters" is selected when there's already a "global" filter
dialog box open).
Keep around pointers to the dialog boxes that contain the "Filter:"
buttons, so that we can arrange that there be only one of them (that was
a side-effect of an earlier attempt at fixing the problems described
above, but it's still useful for keeping multiple competing dialog boxes
from being open - there's more of that to be done).
Make the pointer to the "Open Capture File" dialog box widget static to
"file_dlg.c" - nobody outside of "file_dlg.c cares about it.
svn path=/trunk/; revision=1774
2000-04-01 12:03:42 +00:00
|
|
|
static void
|
2004-01-25 12:25:57 +00:00
|
|
|
filter_dlg_destroy_cb(GtkWidget *win, gpointer data)
|
Split "filter_dialog_cb()" into "filter_dialog_cb()", which pops up a
"global" dialog box when "Edit:Filters" is selected, so that the list of
filters can be edited, and "filter_browse_cb()", which pops up a dialog
box associated with a "Filter:" button and a text entry widget attached
to that button, so that a filter can be selected or saved (although it
also supports the same editing that the "global" dialog box does).
Have "filter_dialog_cb()" connect the window in which the "Filter:"
button lives and the filter dialog box, so that:
if the window in which the "Filter:" button lives goes away, so
does the filter dialog box (as it no longer has a text widget
into which it can stuff the selected filter);
if the "Filter:" button is clicked when there's already a filter
dialog box open, we just reactivate that existing dialog box
rather than popping up a new one.
Also keep a pointer to the "global" filter dialog box, so that we also
arrange that there's only one of them (by reactivating the existing on
if "Edit:Filters" is selected when there's already a "global" filter
dialog box open).
Keep around pointers to the dialog boxes that contain the "Filter:"
buttons, so that we can arrange that there be only one of them (that was
a side-effect of an earlier attempt at fixing the problems described
above, but it's still useful for keeping multiple competing dialog boxes
from being open - there's more of that to be done).
Make the pointer to the "Open Capture File" dialog box widget static to
"file_dlg.c" - nobody outside of "file_dlg.c cares about it.
svn path=/trunk/; revision=1774
2000-04-01 12:03:42 +00:00
|
|
|
{
|
2009-05-01 16:36:04 +00:00
|
|
|
filter_list_type_t list_type = *(filter_list_type_t *)data;
|
|
|
|
GtkWidget *button;
|
Split "filter_dialog_cb()" into "filter_dialog_cb()", which pops up a
"global" dialog box when "Edit:Filters" is selected, so that the list of
filters can be edited, and "filter_browse_cb()", which pops up a dialog
box associated with a "Filter:" button and a text entry widget attached
to that button, so that a filter can be selected or saved (although it
also supports the same editing that the "global" dialog box does).
Have "filter_dialog_cb()" connect the window in which the "Filter:"
button lives and the filter dialog box, so that:
if the window in which the "Filter:" button lives goes away, so
does the filter dialog box (as it no longer has a text widget
into which it can stuff the selected filter);
if the "Filter:" button is clicked when there's already a filter
dialog box open, we just reactivate that existing dialog box
rather than popping up a new one.
Also keep a pointer to the "global" filter dialog box, so that we also
arrange that there's only one of them (by reactivating the existing on
if "Edit:Filters" is selected when there's already a "global" filter
dialog box open).
Keep around pointers to the dialog boxes that contain the "Filter:"
buttons, so that we can arrange that there be only one of them (that was
a side-effect of an earlier attempt at fixing the problems described
above, but it's still useful for keeping multiple competing dialog boxes
from being open - there's more of that to be done).
Make the pointer to the "Open Capture File" dialog box widget static to
"file_dlg.c" - nobody outside of "file_dlg.c cares about it.
svn path=/trunk/; revision=1774
2000-04-01 12:03:42 +00:00
|
|
|
|
2009-05-01 16:36:04 +00:00
|
|
|
/* Get the button that requested that we be popped up, if any.
|
|
|
|
(It should arrange to destroy us if it's destroyed, so
|
|
|
|
that we don't get a pointer to a non-existent window here.) */
|
|
|
|
button = g_object_get_data(G_OBJECT(win), E_FILT_BUTTON_PTR_KEY);
|
Split "filter_dialog_cb()" into "filter_dialog_cb()", which pops up a
"global" dialog box when "Edit:Filters" is selected, so that the list of
filters can be edited, and "filter_browse_cb()", which pops up a dialog
box associated with a "Filter:" button and a text entry widget attached
to that button, so that a filter can be selected or saved (although it
also supports the same editing that the "global" dialog box does).
Have "filter_dialog_cb()" connect the window in which the "Filter:"
button lives and the filter dialog box, so that:
if the window in which the "Filter:" button lives goes away, so
does the filter dialog box (as it no longer has a text widget
into which it can stuff the selected filter);
if the "Filter:" button is clicked when there's already a filter
dialog box open, we just reactivate that existing dialog box
rather than popping up a new one.
Also keep a pointer to the "global" filter dialog box, so that we also
arrange that there's only one of them (by reactivating the existing on
if "Edit:Filters" is selected when there's already a "global" filter
dialog box open).
Keep around pointers to the dialog boxes that contain the "Filter:"
buttons, so that we can arrange that there be only one of them (that was
a side-effect of an earlier attempt at fixing the problems described
above, but it's still useful for keeping multiple competing dialog boxes
from being open - there's more of that to be done).
Make the pointer to the "Open Capture File" dialog box widget static to
"file_dlg.c" - nobody outside of "file_dlg.c cares about it.
svn path=/trunk/; revision=1774
2000-04-01 12:03:42 +00:00
|
|
|
|
2009-05-01 16:36:04 +00:00
|
|
|
if (button != NULL) {
|
|
|
|
/* Tell it we no longer exist. */
|
2008-04-11 16:04:54 +00:00
|
|
|
g_object_set_data(G_OBJECT(button), E_FILT_DIALOG_PTR_KEY, NULL);
|
2009-05-01 16:36:04 +00:00
|
|
|
} else {
|
|
|
|
/* This is an editing dialog popped up from, for example,
|
|
|
|
a menu item; note that we no longer have one. */
|
|
|
|
switch (list_type) {
|
Have separate capture and display filter lists; some filter dialog boxes
use the capture filter lists, and others use the display filter list, as
appropriate.
Have separate menu items for editing the capture and display filter
lists.
Have separate "~/.ethereal/cfilters" and "~/.ethereal/dfilters" files
for the two lists; if either of those files isn't found, we try
"~/.ethereal/filters", which means that you will start out with two
identical lists holding all your filters - if certain filters belong
only in one list, you'll have to delete them by hand from the other
list.
Do I/O error checking when reading and writing filter lists; when
writing a filter list, write it to a new file, and then rename the new
file on top of the old file, so that you don't lose your old filter list
if, for example, you run out of disk space or disk quota.
svn path=/trunk/; revision=2948
2001-01-28 09:13:10 +00:00
|
|
|
|
2001-06-27 10:00:14 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
2009-05-01 16:36:04 +00:00
|
|
|
case CFILTER_EDITED_LIST:
|
|
|
|
g_assert(win == global_cfilter_w);
|
|
|
|
global_cfilter_w = NULL;
|
|
|
|
break;
|
2001-06-27 10:00:14 +00:00
|
|
|
#endif
|
2009-05-01 16:36:04 +00:00
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Remove this from the list of filter dialog windows. */
|
|
|
|
forget_filter_dialog(win, list_type);
|
Split "filter_dialog_cb()" into "filter_dialog_cb()", which pops up a
"global" dialog box when "Edit:Filters" is selected, so that the list of
filters can be edited, and "filter_browse_cb()", which pops up a dialog
box associated with a "Filter:" button and a text entry widget attached
to that button, so that a filter can be selected or saved (although it
also supports the same editing that the "global" dialog box does).
Have "filter_dialog_cb()" connect the window in which the "Filter:"
button lives and the filter dialog box, so that:
if the window in which the "Filter:" button lives goes away, so
does the filter dialog box (as it no longer has a text widget
into which it can stuff the selected filter);
if the "Filter:" button is clicked when there's already a filter
dialog box open, we just reactivate that existing dialog box
rather than popping up a new one.
Also keep a pointer to the "global" filter dialog box, so that we also
arrange that there's only one of them (by reactivating the existing on
if "Edit:Filters" is selected when there's already a "global" filter
dialog box open).
Keep around pointers to the dialog boxes that contain the "Filter:"
buttons, so that we can arrange that there be only one of them (that was
a side-effect of an earlier attempt at fixing the problems described
above, but it's still useful for keeping multiple competing dialog boxes
from being open - there's more of that to be done).
Make the pointer to the "Open Capture File" dialog box widget static to
"file_dlg.c" - nobody outside of "file_dlg.c cares about it.
svn path=/trunk/; revision=1774
2000-04-01 12:03:42 +00:00
|
|
|
}
|
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
static gint
|
2002-11-11 15:39:06 +00:00
|
|
|
filter_sel_list_button_cb(GtkWidget *list, GdkEventButton *event,
|
|
|
|
gpointer data _U_)
|
2000-10-25 16:06:50 +00:00
|
|
|
{
|
2002-11-11 15:39:06 +00:00
|
|
|
void (* func)(GtkWidget *, gpointer, gpointer);
|
2000-10-25 16:06:50 +00:00
|
|
|
gpointer func_arg;
|
2002-03-16 22:02:55 +00:00
|
|
|
gpointer func_activate;
|
2000-10-25 16:06:50 +00:00
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
if (event->type == GDK_2BUTTON_PRESS) {
|
2008-04-11 16:04:54 +00:00
|
|
|
func = g_object_get_data(G_OBJECT(list), E_FILT_DBLFUNC_KEY);
|
|
|
|
func_arg = g_object_get_data(G_OBJECT(list), E_FILT_DBLARG_KEY);
|
|
|
|
func_activate = g_object_get_data(G_OBJECT(list), E_FILT_DBLACTIVATE_KEY);
|
2002-11-03 17:38:45 +00:00
|
|
|
|
|
|
|
if (func)
|
|
|
|
(*func)(list, func_arg, func_activate);
|
|
|
|
}
|
2000-10-25 16:06:50 +00:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
static void
|
|
|
|
filter_sel_list_cb(GtkTreeSelection *sel, gpointer data _U_)
|
In the process of destroying a filter editing dialog box, we get a
selection change event on the list of filters. Unfortunately, this can
happen after some other widgets in that dialog box have already been
destroyed - including some of the widgets that such a selection change
event can change.
This sometimes happened when "filter_prefs_delete()" hadn't been called,
so the mechanism we had been using, with a Boolean datum attached to the
dialog box, set in "filter_prefs_delete()" before we actually destroy
the dialog box, wasn't sufficient to keep that from happening.
Attach to the top-level window data items containing pointers to the
widgets changed when a filter is selected from the list, give each of
those widgets their own destroy callbacks, clear the pointer attached to
the top-level widget when the widget is destroyed, and don't do anything
to the widget when a filter is selected from the list if the pointer for
that widget is null, as that means the widget's been destroyed and we
*can't* do anything to it.
Not all filter editing dialogs created on behalf of a "Filter:" button
next to a text entry box should, when you click "OK", activate the text
entry box; if the text entry box is part of a dialog box with multiple
widgets, the user might not have filled in all of the items in that
dialog box, so you shouldn't activate it for them. Add a mechanism by
which, when creating a filter editing dialog box, you can specify
whether the "OK" button should just fill in the text entry box or should
fill it in and also activate it.
svn path=/trunk/; revision=2922
2001-01-21 01:45:07 +00:00
|
|
|
{
|
2002-11-03 17:38:45 +00:00
|
|
|
GtkWidget *filter_l = GTK_WIDGET(gtk_tree_selection_get_tree_view(sel));
|
|
|
|
GtkWidget *main_w = gtk_widget_get_toplevel(filter_l);
|
|
|
|
GtkTreeModel *model;
|
|
|
|
GtkTreeIter iter;
|
2008-04-11 16:04:54 +00:00
|
|
|
GtkWidget *name_te = g_object_get_data(G_OBJECT(main_w), E_FILT_NAME_TE_KEY);
|
|
|
|
GtkWidget *filter_te = g_object_get_data(G_OBJECT(main_w), E_FILT_FILTER_TE_KEY);
|
|
|
|
GtkWidget *chg_bt = g_object_get_data(G_OBJECT(main_w), E_FILT_CHG_BT_KEY);
|
|
|
|
GtkWidget *copy_bt = g_object_get_data(G_OBJECT(main_w), E_FILT_COPY_BT_KEY);
|
|
|
|
GtkWidget *del_bt = g_object_get_data(G_OBJECT(main_w), E_FILT_DEL_BT_KEY);
|
2002-11-03 17:38:45 +00:00
|
|
|
filter_def *filt;
|
2004-01-25 12:25:57 +00:00
|
|
|
gchar *name = NULL, *strval = NULL;
|
2002-11-03 17:38:45 +00:00
|
|
|
GList *flp;
|
|
|
|
gint sensitivity = FALSE;
|
|
|
|
|
|
|
|
if (gtk_tree_selection_get_selected(sel, &model, &iter)) {
|
|
|
|
gtk_tree_model_get(model, &iter, 1, &flp, -1);
|
|
|
|
if (flp) {
|
|
|
|
filt = (filter_def *) flp->data;
|
2004-01-25 12:25:57 +00:00
|
|
|
name = g_strdup(filt->name);
|
|
|
|
strval = g_strdup(filt->strval);
|
2002-11-03 17:38:45 +00:00
|
|
|
sensitivity = TRUE;
|
|
|
|
}
|
1998-09-16 02:39:15 +00:00
|
|
|
}
|
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
/*
|
|
|
|
* Did you know that this function is called when the window is destroyed?
|
|
|
|
* Funny, that.
|
|
|
|
* This means that we have to:
|
|
|
|
*
|
2009-05-01 16:36:04 +00:00
|
|
|
* attach to the top-level window data items containing pointers to
|
|
|
|
* the widgets we affect here;
|
2002-11-03 17:38:45 +00:00
|
|
|
*
|
2009-05-01 16:36:04 +00:00
|
|
|
* give each of those widgets their own destroy callbacks;
|
2002-11-03 17:38:45 +00:00
|
|
|
*
|
2009-05-01 16:36:04 +00:00
|
|
|
* clear that pointer when the widget is destroyed;
|
2002-11-03 17:38:45 +00:00
|
|
|
*
|
2009-05-01 16:36:04 +00:00
|
|
|
* don't do anything to the widget if the pointer we get back is
|
|
|
|
* null;
|
2002-11-03 17:38:45 +00:00
|
|
|
*
|
|
|
|
* so that if we're called after any of the widgets we'd affect are
|
|
|
|
* destroyed, we know that we shouldn't do anything to those widgets.
|
|
|
|
*/
|
|
|
|
if (name_te != NULL)
|
2004-01-25 12:25:57 +00:00
|
|
|
gtk_entry_set_text(GTK_ENTRY(name_te), name ? name : "");
|
2002-11-03 17:38:45 +00:00
|
|
|
if (filter_te != NULL)
|
2004-01-25 12:25:57 +00:00
|
|
|
gtk_entry_set_text(GTK_ENTRY(filter_te), strval ? strval : "");
|
2002-11-03 17:38:45 +00:00
|
|
|
if (chg_bt != NULL)
|
|
|
|
gtk_widget_set_sensitive(chg_bt, sensitivity);
|
|
|
|
if (copy_bt != NULL)
|
|
|
|
gtk_widget_set_sensitive(copy_bt, sensitivity);
|
|
|
|
if (del_bt != NULL)
|
|
|
|
gtk_widget_set_sensitive(del_bt, sensitivity);
|
2009-03-13 22:06:48 +00:00
|
|
|
g_free(name);
|
|
|
|
g_free(strval);
|
1998-09-16 02:39:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* To do: add input checking to each of these callbacks */
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-01-21 03:30:24 +00:00
|
|
|
/* Structure containing arguments to be passed to "new_filter_cb()".
|
|
|
|
|
|
|
|
"active_filter_l" is the list in the dialog box in which "New" or
|
|
|
|
"Copy" was clicked; in that dialog box, but not in any other dialog
|
|
|
|
box, we select the newly created list item.
|
|
|
|
|
|
|
|
"nflp" is the GList member in the model (filter list) for the new
|
|
|
|
filter. */
|
|
|
|
typedef struct {
|
2009-05-01 16:36:04 +00:00
|
|
|
GtkWidget *active_filter_l;
|
|
|
|
GList *nflp;
|
2001-01-21 03:30:24 +00:00
|
|
|
} new_filter_cb_args_t;
|
|
|
|
|
|
|
|
static void
|
|
|
|
new_filter_cb(gpointer data, gpointer user_data)
|
|
|
|
{
|
2002-11-03 17:38:45 +00:00
|
|
|
GtkWidget *main_w = data;
|
|
|
|
GtkTreeView *filter_l;
|
|
|
|
GtkListStore *store;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
new_filter_cb_args_t *args = user_data;
|
|
|
|
filter_def *nfilt = args->nflp->data;
|
|
|
|
|
2008-04-11 16:04:54 +00:00
|
|
|
filter_l = GTK_TREE_VIEW(g_object_get_data(G_OBJECT(main_w), E_FILT_FILTER_L_KEY));
|
2002-11-03 17:38:45 +00:00
|
|
|
store = GTK_LIST_STORE(gtk_tree_view_get_model(filter_l));
|
|
|
|
gtk_list_store_append(store, &iter);
|
|
|
|
gtk_list_store_set(store, &iter, 0, nfilt->name, 1, args->nflp, -1);
|
|
|
|
if (GTK_WIDGET(filter_l) == args->active_filter_l) {
|
|
|
|
/* Select the item. */
|
|
|
|
gtk_tree_selection_select_iter(gtk_tree_view_get_selection(filter_l),
|
|
|
|
&iter);
|
|
|
|
}
|
2001-01-21 03:30:24 +00:00
|
|
|
}
|
|
|
|
|
2000-02-12 06:46:54 +00:00
|
|
|
static void
|
2001-01-21 03:30:24 +00:00
|
|
|
filter_new_bt_clicked_cb(GtkWidget *w, gpointer data)
|
In the process of destroying a filter editing dialog box, we get a
selection change event on the list of filters. Unfortunately, this can
happen after some other widgets in that dialog box have already been
destroyed - including some of the widgets that such a selection change
event can change.
This sometimes happened when "filter_prefs_delete()" hadn't been called,
so the mechanism we had been using, with a Boolean datum attached to the
dialog box, set in "filter_prefs_delete()" before we actually destroy
the dialog box, wasn't sufficient to keep that from happening.
Attach to the top-level window data items containing pointers to the
widgets changed when a filter is selected from the list, give each of
those widgets their own destroy callbacks, clear the pointer attached to
the top-level widget when the widget is destroyed, and don't do anything
to the widget when a filter is selected from the list if the pointer for
that widget is null, as that means the widget's been destroyed and we
*can't* do anything to it.
Not all filter editing dialogs created on behalf of a "Filter:" button
next to a text entry box should, when you click "OK", activate the text
entry box; if the text entry box is part of a dialog box with multiple
widgets, the user might not have filled in all of the items in that
dialog box, so you shouldn't activate it for them. Add a mechanism by
which, when creating a filter editing dialog box, you can specify
whether the "OK" button should just fill in the text entry box or should
fill it in and also activate it.
svn path=/trunk/; revision=2922
2001-01-21 01:45:07 +00:00
|
|
|
{
|
2009-05-01 16:36:04 +00:00
|
|
|
GtkWidget *main_w = gtk_widget_get_toplevel(w);
|
|
|
|
GtkWidget *name_te = g_object_get_data(G_OBJECT(main_w), E_FILT_NAME_TE_KEY);
|
|
|
|
GtkWidget *filter_te = g_object_get_data(G_OBJECT(main_w), E_FILT_FILTER_TE_KEY);
|
|
|
|
GtkWidget *filter_l = g_object_get_data(G_OBJECT(main_w), E_FILT_FILTER_L_KEY);
|
|
|
|
filter_list_type_t list_type = *(filter_list_type_t *)data;
|
|
|
|
GList *fl_entry;
|
|
|
|
const gchar *name, *strval;
|
|
|
|
new_filter_cb_args_t args;
|
|
|
|
|
|
|
|
name = gtk_entry_get_text(GTK_ENTRY(name_te));
|
|
|
|
strval = gtk_entry_get_text(GTK_ENTRY(filter_te));
|
|
|
|
|
|
|
|
/* if the user didn't entered a name, set default one */
|
|
|
|
if (strlen(name) == 0) {
|
|
|
|
name = "new";
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if the user didn't entered a string value, set default one */
|
|
|
|
if (strlen(strval) == 0) {
|
|
|
|
strval = "new";
|
|
|
|
}
|
2004-01-25 12:25:57 +00:00
|
|
|
|
Have separate capture and display filter lists; some filter dialog boxes
use the capture filter lists, and others use the display filter list, as
appropriate.
Have separate menu items for editing the capture and display filter
lists.
Have separate "~/.ethereal/cfilters" and "~/.ethereal/dfilters" files
for the two lists; if either of those files isn't found, we try
"~/.ethereal/filters", which means that you will start out with two
identical lists holding all your filters - if certain filters belong
only in one list, you'll have to delete them by hand from the other
list.
Do I/O error checking when reading and writing filter lists; when
writing a filter list, write it to a new file, and then rename the new
file on top of the old file, so that you don't lose your old filter list
if, for example, you run out of disk space or disk quota.
svn path=/trunk/; revision=2948
2001-01-28 09:13:10 +00:00
|
|
|
/* Add a new entry to the filter list. */
|
2006-10-01 17:59:30 +00:00
|
|
|
fl_entry = add_to_filter_list(list_type, name, strval);
|
2001-01-21 03:30:24 +00:00
|
|
|
|
|
|
|
/* Update all the filter list widgets, not just the one in
|
|
|
|
the dialog box in which we clicked on "Copy". */
|
|
|
|
args.active_filter_l = filter_l;
|
Have separate capture and display filter lists; some filter dialog boxes
use the capture filter lists, and others use the display filter list, as
appropriate.
Have separate menu items for editing the capture and display filter
lists.
Have separate "~/.ethereal/cfilters" and "~/.ethereal/dfilters" files
for the two lists; if either of those files isn't found, we try
"~/.ethereal/filters", which means that you will start out with two
identical lists holding all your filters - if certain filters belong
only in one list, you'll have to delete them by hand from the other
list.
Do I/O error checking when reading and writing filter lists; when
writing a filter list, write it to a new file, and then rename the new
file on top of the old file, so that you don't lose your old filter list
if, for example, you run out of disk space or disk quota.
svn path=/trunk/; revision=2948
2001-01-28 09:13:10 +00:00
|
|
|
args.nflp = fl_entry;
|
2006-10-01 17:59:30 +00:00
|
|
|
g_list_foreach(get_filter_dialog_list(list_type), new_filter_cb, &args);
|
2004-01-25 12:25:57 +00:00
|
|
|
|
1998-09-16 02:39:15 +00:00
|
|
|
}
|
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
static gboolean
|
|
|
|
chg_list_item_cb(GtkTreeModel *model, GtkTreePath *path _U_, GtkTreeIter *iter,
|
|
|
|
gpointer data)
|
2001-01-21 03:30:24 +00:00
|
|
|
{
|
2002-11-03 17:38:45 +00:00
|
|
|
GList *flp = data;
|
|
|
|
filter_def *filt = flp->data;
|
|
|
|
GList *nl_model;
|
|
|
|
|
|
|
|
gtk_tree_model_get(model, iter, 1, &nl_model, -1);
|
|
|
|
/* Is this the item corresponding to the filter list item in question? */
|
|
|
|
if (flp == nl_model) {
|
|
|
|
/* Yes - change the label to correspond to the new name for the
|
|
|
|
* filter. */
|
|
|
|
gtk_list_store_set(GTK_LIST_STORE(model), iter, 0, filt->name, -1);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
2001-01-21 03:30:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
chg_filter_cb(gpointer data, gpointer user_data)
|
|
|
|
{
|
2002-11-03 17:38:45 +00:00
|
|
|
GtkWidget *main_w = data;
|
2008-04-11 16:04:54 +00:00
|
|
|
GtkWidget *filter_l = g_object_get_data(G_OBJECT(main_w), E_FILT_FILTER_L_KEY);
|
2002-11-03 17:38:45 +00:00
|
|
|
|
|
|
|
gtk_tree_model_foreach(gtk_tree_view_get_model(GTK_TREE_VIEW(filter_l)),
|
|
|
|
chg_list_item_cb, user_data);
|
2001-01-21 03:30:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-01-25 15:10:36 +00:00
|
|
|
filter_name_te_changed_cb(GtkWidget *w, gpointer data)
|
In the process of destroying a filter editing dialog box, we get a
selection change event on the list of filters. Unfortunately, this can
happen after some other widgets in that dialog box have already been
destroyed - including some of the widgets that such a selection change
event can change.
This sometimes happened when "filter_prefs_delete()" hadn't been called,
so the mechanism we had been using, with a Boolean datum attached to the
dialog box, set in "filter_prefs_delete()" before we actually destroy
the dialog box, wasn't sufficient to keep that from happening.
Attach to the top-level window data items containing pointers to the
widgets changed when a filter is selected from the list, give each of
those widgets their own destroy callbacks, clear the pointer attached to
the top-level widget when the widget is destroyed, and don't do anything
to the widget when a filter is selected from the list if the pointer for
that widget is null, as that means the widget's been destroyed and we
*can't* do anything to it.
Not all filter editing dialogs created on behalf of a "Filter:" button
next to a text entry box should, when you click "OK", activate the text
entry box; if the text entry box is part of a dialog box with multiple
widgets, the user might not have filled in all of the items in that
dialog box, so you shouldn't activate it for them. Add a mechanism by
which, when creating a filter editing dialog box, you can specify
whether the "OK" button should just fill in the text entry box or should
fill it in and also activate it.
svn path=/trunk/; revision=2922
2001-01-21 01:45:07 +00:00
|
|
|
{
|
2002-11-03 17:38:45 +00:00
|
|
|
GtkWidget *main_w = gtk_widget_get_toplevel(w);
|
2008-04-11 16:04:54 +00:00
|
|
|
GtkWidget *name_te = g_object_get_data(G_OBJECT(main_w), E_FILT_NAME_TE_KEY);
|
|
|
|
GtkWidget *filter_te = g_object_get_data(G_OBJECT(main_w), E_FILT_FILTER_TE_KEY);
|
|
|
|
GtkWidget *filter_l = g_object_get_data(G_OBJECT(main_w), E_FILT_FILTER_L_KEY);
|
2002-11-03 17:38:45 +00:00
|
|
|
filter_def *filt;
|
|
|
|
GList *fl_entry;
|
2006-10-01 17:59:30 +00:00
|
|
|
filter_list_type_t list_type = *(filter_list_type_t *)data;
|
2004-01-25 12:25:57 +00:00
|
|
|
const gchar *name = "";
|
|
|
|
const gchar *strval = "";
|
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
GtkTreeSelection *sel;
|
|
|
|
GtkTreeModel *model;
|
|
|
|
GtkTreeIter iter;
|
1998-09-16 02:39:15 +00:00
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(filter_l));
|
|
|
|
name = gtk_entry_get_text(GTK_ENTRY(name_te));
|
|
|
|
strval = gtk_entry_get_text(GTK_ENTRY(filter_te));
|
|
|
|
|
2006-10-01 17:59:30 +00:00
|
|
|
if (DFILTER_EDITED_LIST == list_type) {
|
2004-01-25 12:25:57 +00:00
|
|
|
/* colorize filter string entry */
|
2004-01-25 15:10:36 +00:00
|
|
|
filter_te_syntax_check_cb(filter_te);
|
2004-01-25 12:25:57 +00:00
|
|
|
}
|
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
/* if something was selected */
|
|
|
|
if (gtk_tree_selection_get_selected(sel, &model, &iter)) {
|
|
|
|
gtk_tree_model_get(model, &iter, 1, &fl_entry, -1);
|
|
|
|
if (fl_entry != NULL) {
|
|
|
|
filt = (filter_def *) fl_entry->data;
|
|
|
|
|
|
|
|
if (strlen(name) > 0 && strlen(strval) > 0 && filt) {
|
|
|
|
g_free(filt->name);
|
|
|
|
g_free(filt->strval);
|
|
|
|
filt->name = g_strdup(name);
|
|
|
|
filt->strval = g_strdup(strval);
|
|
|
|
|
|
|
|
/* Update all the filter list widgets, not just the one in
|
|
|
|
the dialog box in which we clicked on "Copy". */
|
2006-10-01 17:59:30 +00:00
|
|
|
g_list_foreach(get_filter_dialog_list(list_type), chg_filter_cb,
|
2002-11-03 17:38:45 +00:00
|
|
|
fl_entry);
|
|
|
|
}
|
|
|
|
}
|
1998-09-16 02:39:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-01-21 03:30:24 +00:00
|
|
|
static void
|
|
|
|
delete_filter_cb(gpointer data, gpointer user_data)
|
|
|
|
{
|
2002-11-03 17:38:45 +00:00
|
|
|
GtkWidget *main_w = data;
|
2008-04-11 16:04:54 +00:00
|
|
|
GtkWidget *filter_l = g_object_get_data(G_OBJECT(main_w), E_FILT_FILTER_L_KEY);
|
2002-11-03 17:38:45 +00:00
|
|
|
gchar *pos = (gchar *)user_data;
|
|
|
|
GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(filter_l));
|
|
|
|
GtkTreeIter iter;
|
In the process of destroying a filter editing dialog box, we get a
selection change event on the list of filters. Unfortunately, this can
happen after some other widgets in that dialog box have already been
destroyed - including some of the widgets that such a selection change
event can change.
This sometimes happened when "filter_prefs_delete()" hadn't been called,
so the mechanism we had been using, with a Boolean datum attached to the
dialog box, set in "filter_prefs_delete()" before we actually destroy
the dialog box, wasn't sufficient to keep that from happening.
Attach to the top-level window data items containing pointers to the
widgets changed when a filter is selected from the list, give each of
those widgets their own destroy callbacks, clear the pointer attached to
the top-level widget when the widget is destroyed, and don't do anything
to the widget when a filter is selected from the list if the pointer for
that widget is null, as that means the widget's been destroyed and we
*can't* do anything to it.
Not all filter editing dialogs created on behalf of a "Filter:" button
next to a text entry box should, when you click "OK", activate the text
entry box; if the text entry box is part of a dialog box with multiple
widgets, the user might not have filled in all of the items in that
dialog box, so you shouldn't activate it for them. Add a mechanism by
which, when creating a filter editing dialog box, you can specify
whether the "OK" button should just fill in the text entry box or should
fill it in and also activate it.
svn path=/trunk/; revision=2922
2001-01-21 01:45:07 +00:00
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
gtk_tree_model_get_iter_from_string(model, &iter, pos);
|
|
|
|
gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
|
In the process of destroying a filter editing dialog box, we get a
selection change event on the list of filters. Unfortunately, this can
happen after some other widgets in that dialog box have already been
destroyed - including some of the widgets that such a selection change
event can change.
This sometimes happened when "filter_prefs_delete()" hadn't been called,
so the mechanism we had been using, with a Boolean datum attached to the
dialog box, set in "filter_prefs_delete()" before we actually destroy
the dialog box, wasn't sufficient to keep that from happening.
Attach to the top-level window data items containing pointers to the
widgets changed when a filter is selected from the list, give each of
those widgets their own destroy callbacks, clear the pointer attached to
the top-level widget when the widget is destroyed, and don't do anything
to the widget when a filter is selected from the list if the pointer for
that widget is null, as that means the widget's been destroyed and we
*can't* do anything to it.
Not all filter editing dialogs created on behalf of a "Filter:" button
next to a text entry box should, when you click "OK", activate the text
entry box; if the text entry box is part of a dialog box with multiple
widgets, the user might not have filled in all of the items in that
dialog box, so you shouldn't activate it for them. Add a mechanism by
which, when creating a filter editing dialog box, you can specify
whether the "OK" button should just fill in the text entry box or should
fill it in and also activate it.
svn path=/trunk/; revision=2922
2001-01-21 01:45:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-01-21 03:30:24 +00:00
|
|
|
filter_del_bt_clicked_cb(GtkWidget *w, gpointer data)
|
In the process of destroying a filter editing dialog box, we get a
selection change event on the list of filters. Unfortunately, this can
happen after some other widgets in that dialog box have already been
destroyed - including some of the widgets that such a selection change
event can change.
This sometimes happened when "filter_prefs_delete()" hadn't been called,
so the mechanism we had been using, with a Boolean datum attached to the
dialog box, set in "filter_prefs_delete()" before we actually destroy
the dialog box, wasn't sufficient to keep that from happening.
Attach to the top-level window data items containing pointers to the
widgets changed when a filter is selected from the list, give each of
those widgets their own destroy callbacks, clear the pointer attached to
the top-level widget when the widget is destroyed, and don't do anything
to the widget when a filter is selected from the list if the pointer for
that widget is null, as that means the widget's been destroyed and we
*can't* do anything to it.
Not all filter editing dialogs created on behalf of a "Filter:" button
next to a text entry box should, when you click "OK", activate the text
entry box; if the text entry box is part of a dialog box with multiple
widgets, the user might not have filled in all of the items in that
dialog box, so you shouldn't activate it for them. Add a mechanism by
which, when creating a filter editing dialog box, you can specify
whether the "OK" button should just fill in the text entry box or should
fill it in and also activate it.
svn path=/trunk/; revision=2922
2001-01-21 01:45:07 +00:00
|
|
|
{
|
2002-11-03 17:38:45 +00:00
|
|
|
GtkWidget *main_w = gtk_widget_get_toplevel(w);
|
2008-04-11 16:04:54 +00:00
|
|
|
GtkWidget *filter_l = g_object_get_data(G_OBJECT(main_w), E_FILT_FILTER_L_KEY);
|
2006-10-01 17:59:30 +00:00
|
|
|
filter_list_type_t list_type = *(filter_list_type_t *)data;
|
2002-11-03 17:38:45 +00:00
|
|
|
GList *fl_entry;
|
|
|
|
gchar *pos;
|
|
|
|
GtkTreeSelection *sel;
|
|
|
|
GtkTreeModel *model;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreePath *path;
|
|
|
|
|
|
|
|
sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(filter_l));
|
|
|
|
/* If something was selected */
|
|
|
|
if (gtk_tree_selection_get_selected(sel, &model, &iter)) {
|
|
|
|
gtk_tree_model_get(model, &iter, 1, &fl_entry, -1);
|
|
|
|
path = gtk_tree_model_get_path(model, &iter);
|
|
|
|
pos = gtk_tree_path_to_string(path);
|
|
|
|
gtk_tree_path_free(path);
|
|
|
|
if (fl_entry != NULL) {
|
|
|
|
/* Remove the entry from the filter list. */
|
2006-10-01 17:59:30 +00:00
|
|
|
remove_from_filter_list(list_type, fl_entry);
|
2002-11-03 17:38:45 +00:00
|
|
|
|
|
|
|
/* Update all the filter list widgets, not just the one in
|
|
|
|
the dialog box in which we clicked on "Delete". */
|
2006-10-01 17:59:30 +00:00
|
|
|
g_list_foreach(get_filter_dialog_list(list_type), delete_filter_cb, pos);
|
2002-11-03 17:38:45 +00:00
|
|
|
}
|
|
|
|
g_free(pos);
|
2002-08-28 21:04:11 +00:00
|
|
|
}
|
1998-09-16 02:39:15 +00:00
|
|
|
}
|
|
|
|
|
2004-01-25 15:10:36 +00:00
|
|
|
void
|
2004-01-25 12:25:57 +00:00
|
|
|
filter_add_expr_bt_cb(GtkWidget *w _U_, gpointer main_w_arg)
|
2001-01-02 01:32:21 +00:00
|
|
|
{
|
2009-05-01 16:36:04 +00:00
|
|
|
GtkWidget *main_w = GTK_WIDGET(main_w_arg);
|
|
|
|
GtkWidget *filter_te, *dfilter_w;
|
1998-09-16 02:39:15 +00:00
|
|
|
|
2009-05-01 16:36:04 +00:00
|
|
|
filter_te = g_object_get_data(G_OBJECT(main_w), E_FILT_FILTER_TE_KEY);
|
|
|
|
dfilter_w = dfilter_expr_dlg_new(filter_te);
|
2007-06-17 00:54:58 +00:00
|
|
|
|
2009-05-01 16:36:04 +00:00
|
|
|
/* If we're opening a series of modal dialogs (such as when going
|
|
|
|
* through file->open, make the latest dialog modal also so that it
|
|
|
|
* takes over "control" from the other modal dialogs. Also set
|
|
|
|
* the transient property of the new dialog so the user doesn't try
|
|
|
|
* to interact with the previous window when they can't.
|
2007-09-05 14:59:37 +00:00
|
|
|
* XXX: containing widget might be the Filter Toolbar */
|
|
|
|
|
2009-05-01 16:36:04 +00:00
|
|
|
if ( GTK_IS_WINDOW(main_w) && gtk_window_get_modal(GTK_WINDOW(main_w))) {
|
|
|
|
gtk_window_set_modal(GTK_WINDOW(dfilter_w), TRUE);
|
|
|
|
gtk_window_set_transient_for(GTK_WINDOW(dfilter_w),
|
|
|
|
GTK_WINDOW(main_w));
|
|
|
|
}
|
1998-09-16 02:39:15 +00:00
|
|
|
}
|
|
|
|
|
2004-02-28 04:18:47 +00:00
|
|
|
static void
|
|
|
|
color_filter_te(GtkWidget *w, guint16 red, guint16 green, guint16 blue)
|
2004-01-25 15:10:36 +00:00
|
|
|
{
|
2008-10-12 13:41:04 +00:00
|
|
|
static GdkColor black = { 0, 0, 0, 0 };
|
2004-01-25 15:10:36 +00:00
|
|
|
GdkColor bg;
|
|
|
|
|
2004-02-28 04:18:47 +00:00
|
|
|
bg.pixel = 0;
|
|
|
|
bg.red = red;
|
|
|
|
bg.green = green;
|
|
|
|
bg.blue = blue;
|
|
|
|
|
2008-10-12 13:41:04 +00:00
|
|
|
gtk_widget_modify_text(w, GTK_STATE_NORMAL, &black);
|
|
|
|
gtk_widget_modify_base(w, GTK_STATE_NORMAL, &bg);
|
|
|
|
#if GTK_CHECK_VERSION(2,12,0)
|
|
|
|
gtk_widget_modify_cursor(w, &black, &black);
|
|
|
|
#endif
|
2004-02-28 04:18:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
colorize_filter_te_as_empty(GtkWidget *w)
|
|
|
|
{
|
2008-10-12 13:41:04 +00:00
|
|
|
/* use defaults */
|
|
|
|
gtk_widget_modify_text(w, GTK_STATE_NORMAL, NULL);
|
|
|
|
gtk_widget_modify_base(w, GTK_STATE_NORMAL, NULL);
|
|
|
|
#if GTK_CHECK_VERSION(2,12,0)
|
|
|
|
gtk_widget_modify_cursor(w, NULL, NULL);
|
|
|
|
#endif
|
2004-02-28 04:18:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
colorize_filter_te_as_invalid(GtkWidget *w)
|
|
|
|
{
|
|
|
|
/* light red */
|
|
|
|
color_filter_te(w, 0xFFFF, 0xAFFF, 0xAFFF);
|
|
|
|
}
|
|
|
|
|
2009-09-29 19:20:48 +00:00
|
|
|
static void
|
2008-01-31 19:50:38 +00:00
|
|
|
colorize_filter_te_as_deprecated(GtkWidget *w)
|
|
|
|
{
|
|
|
|
/* light yellow */
|
|
|
|
color_filter_te(w, 0xFFFF, 0xFFFF, 0xAFFF);
|
|
|
|
}
|
|
|
|
|
2004-02-28 04:18:47 +00:00
|
|
|
void
|
|
|
|
colorize_filter_te_as_valid(GtkWidget *w)
|
|
|
|
{
|
|
|
|
/* light green */
|
|
|
|
color_filter_te(w, 0xAFFF, 0xFFFF, 0xAFFF);
|
|
|
|
}
|
|
|
|
|
2009-11-24 19:24:09 +00:00
|
|
|
/*
|
|
|
|
* XXX This calls dfilter_compile, which might call get_host_ipaddr or
|
|
|
|
* get_host_ipaddr6. Either of of these will freeze the UI if the host
|
|
|
|
* name resolution takes a long time to complete. We need to work
|
|
|
|
* around this, either by disabling host name resolution or by doing
|
|
|
|
* the resolution asynchronously.
|
|
|
|
*
|
|
|
|
* We could use a separate thread but we have be careful to only call
|
|
|
|
* GTK+/GDK routines from the main thread. From the GDK threads
|
|
|
|
* documentation:
|
|
|
|
*
|
|
|
|
* "With the Win32 backend, GDK calls should not be attempted from
|
|
|
|
* multiple threads at all."
|
|
|
|
*/
|
|
|
|
|
2004-02-28 04:18:47 +00:00
|
|
|
void
|
|
|
|
filter_te_syntax_check_cb(GtkWidget *w)
|
|
|
|
{
|
|
|
|
const gchar *strval;
|
|
|
|
dfilter_t *dfp;
|
2008-01-31 19:50:38 +00:00
|
|
|
GPtrArray *depr = NULL;
|
2008-10-23 14:30:35 +00:00
|
|
|
gboolean use_statusbar;
|
2008-01-31 19:50:38 +00:00
|
|
|
gchar *msg;
|
2008-10-10 17:00:38 +00:00
|
|
|
guchar c;
|
2008-01-31 19:50:38 +00:00
|
|
|
|
2004-01-25 15:10:36 +00:00
|
|
|
strval = gtk_entry_get_text(GTK_ENTRY(w));
|
2008-10-23 14:30:35 +00:00
|
|
|
use_statusbar = g_object_get_data(G_OBJECT(w), E_FILT_FIELD_USE_STATUSBAR_KEY) ? TRUE : FALSE;
|
|
|
|
|
|
|
|
if (use_statusbar) {
|
2009-05-01 16:36:04 +00:00
|
|
|
statusbar_pop_filter_msg();
|
2008-10-23 14:30:35 +00:00
|
|
|
}
|
2004-01-25 15:10:36 +00:00
|
|
|
|
|
|
|
/* colorize filter string entry */
|
2008-10-10 17:00:38 +00:00
|
|
|
if (g_object_get_data(G_OBJECT(w), E_FILT_FIELD_NAME_ONLY_KEY) &&
|
2009-05-01 16:36:04 +00:00
|
|
|
strval && (c = proto_check_field_name(strval)) != 0)
|
2008-10-10 17:00:38 +00:00
|
|
|
{
|
|
|
|
colorize_filter_te_as_invalid(w);
|
2009-05-01 16:36:04 +00:00
|
|
|
if (use_statusbar) {
|
|
|
|
msg = g_strdup_printf(" Illegal character in field name: '%c'", c);
|
|
|
|
statusbar_push_filter_msg(msg);
|
|
|
|
g_free(msg);
|
|
|
|
}
|
2008-10-10 17:00:38 +00:00
|
|
|
} else if (strval && dfilter_compile(strval, &dfp)) {
|
2009-05-01 16:36:04 +00:00
|
|
|
if (dfp != NULL) {
|
|
|
|
depr = dfilter_deprecated_tokens(dfp);
|
2008-01-31 19:50:38 +00:00
|
|
|
}
|
|
|
|
if (strlen(strval) == 0) {
|
2004-02-28 04:18:47 +00:00
|
|
|
colorize_filter_te_as_empty(w);
|
2008-01-31 19:50:38 +00:00
|
|
|
} else if (depr) {
|
|
|
|
/* You keep using that word. I do not think it means what you think it means. */
|
|
|
|
colorize_filter_te_as_deprecated(w);
|
2009-05-01 16:36:04 +00:00
|
|
|
if (use_statusbar) {
|
|
|
|
/*
|
|
|
|
* We're being lazy and only printing the first "problem" token.
|
|
|
|
* Would it be better to print all of them?
|
|
|
|
*/
|
|
|
|
msg = g_strdup_printf(" \"%s\" may have unexpected results (see the User's Guide)",
|
|
|
|
(const char *) g_ptr_array_index(depr, 0));
|
2009-11-04 00:02:52 +00:00
|
|
|
statusbar_push_temporary_msg(msg);
|
2009-05-01 16:36:04 +00:00
|
|
|
g_free(msg);
|
|
|
|
}
|
2008-01-31 19:50:38 +00:00
|
|
|
} else {
|
2004-02-28 04:18:47 +00:00
|
|
|
colorize_filter_te_as_valid(w);
|
2008-01-31 19:50:38 +00:00
|
|
|
}
|
2009-09-01 18:16:55 +00:00
|
|
|
dfilter_free(dfp);
|
2008-01-31 19:50:38 +00:00
|
|
|
} else {
|
2004-02-28 04:18:47 +00:00
|
|
|
colorize_filter_te_as_invalid(w);
|
2009-05-01 16:36:04 +00:00
|
|
|
if (use_statusbar) {
|
2009-05-28 20:25:26 +00:00
|
|
|
if (dfilter_error_msg) {
|
|
|
|
msg = g_strdup_printf(" Invalid filter: %s", dfilter_error_msg);
|
|
|
|
statusbar_push_filter_msg(msg);
|
|
|
|
g_free(msg);
|
|
|
|
} else {
|
|
|
|
statusbar_push_filter_msg(" Invalid filter");
|
|
|
|
}
|
2009-05-01 16:36:04 +00:00
|
|
|
}
|
2008-01-31 19:50:38 +00:00
|
|
|
}
|
2004-01-25 15:10:36 +00:00
|
|
|
}
|
2009-05-01 16:36:04 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Editor modelines
|
|
|
|
*
|
|
|
|
* Local Variables:
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: nil
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* ex: set shiftwidth=4 tabstop=8 expandtab
|
|
|
|
* :indentSize=4:tabSize=8:noTabs=true:
|
|
|
|
*/
|
|
|
|
|