gtkfilefilter.c 16.6 KB
Newer Older
Cody Russell's avatar
Cody Russell committed
1
/* GTK - The GIMP Toolkit
Owen Taylor's avatar
Owen Taylor committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
 * gtkfilefilter.c: Filters for selecting a file subset
 * Copyright (C) 2003, Red Hat, Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
/**
 * SECTION:gtkfilefilter
 * @Short_description: A filter for selecting a file subset
 * @Title: GtkFileFilter
 *
 * A GtkFileFilter can be used to restrict the files being shown in a
 * #GtkFileChooser. Files can be filtered based on their name (with
 * gtk_file_filter_add_pattern()), on their mime type (with
 * gtk_file_filter_add_mime_type()), or by a custom filter function
 * (with gtk_file_filter_add_custom()).
 *
 * Filtering by mime types handles aliasing and subclassing of mime
 * types; e.g. a filter for text/plain also matches a file with mime
 * type application/rtf, since application/rtf is a subclass of
 * text/plain. Note that #GtkFileFilter allows wildcards for the
36
 * subtype of a mime type, so you can e.g. filter for image/*.
37 38 39 40 41
 *
 * Normally, filters are used by adding them to a #GtkFileChooser,
 * see gtk_file_chooser_add_filter(), but it is also possible
 * to manually use a filter on a file with gtk_file_filter_filter().
 *
42 43 44 45
 * <refsect2 id="GtkFileFilter-BUILDER-UI">
 * <title>GtkFileFilter as GtkBuildable</title>
 * <para>
 * The GtkFileFilter implementation of the GtkBuildable interface
46 47 48
 * supports adding rules using the &lt;mime-types&gt;, &lt;patterns&gt; and
 * &lt;applications&gt; elements and listing the rules within. Specifying
 * a &lt;mime-type&gt; or &lt;pattern&gt; is the same
49 50 51 52 53 54 55 56
 * as calling gtk_recent_filter_add_mime_type() or gtk_recent_filter_add_pattern()
 *
 * <example>
 * <title>A UI definition fragment specifying GtkFileFilter rules</title>
 * <programlisting><![CDATA[
 * <object class="GtkFileFilter">
 *   <mime-types>
 *     <mime-type>text/plain</mime-type>
57
 *     <mime-type>image/&ast;</mime-type>
58 59 60 61 62 63 64 65 66 67 68
 *   </mime-types>
 *   <patterns>
 *     <pattern>*.txt</pattern>
 *     <pattern>*.png</pattern>
 *   </patterns>
 * </object>
 * ]]></programlisting>
 * </example>
 * </para>
 * </refsect2>
 *
69 70 71
 * @see_also: #GtkFileChooser
 */

72
#include "config.h"
Owen Taylor's avatar
Owen Taylor committed
73 74
#include <string.h>

Emmanuele Bassi's avatar
Emmanuele Bassi committed
75 76
#include <gdk-pixbuf/gdk-pixbuf.h>

77
#include "gtkfilefilter.h"
78
#include "gtkbuildable.h"
79
#include "gtkintl.h"
80
#include "gtkprivate.h"
81

Owen Taylor's avatar
Owen Taylor committed
82 83 84 85 86 87 88 89 90 91
typedef struct _GtkFileFilterClass GtkFileFilterClass;
typedef struct _FilterRule FilterRule;

#define GTK_FILE_FILTER_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_FILE_FILTER, GtkFileFilterClass))
#define GTK_IS_FILE_FILTER_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_FILE_FILTER))
#define GTK_FILE_FILTER_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_FILE_FILTER, GtkFileFilterClass))

typedef enum {
  FILTER_RULE_PATTERN,
  FILTER_RULE_MIME_TYPE,
92
  FILTER_RULE_PIXBUF_FORMATS,
93
  FILTER_RULE_CUSTOM
Owen Taylor's avatar
Owen Taylor committed
94 95 96 97
} FilterRuleType;

struct _GtkFileFilterClass
{
98
  GInitiallyUnownedClass parent_class;
Owen Taylor's avatar
Owen Taylor committed
99 100 101 102
};

struct _GtkFileFilter
{
103 104
  GInitiallyUnowned parent_instance;

Owen Taylor's avatar
Owen Taylor committed
105 106 107 108 109 110 111 112 113 114 115 116 117 118
  gchar *name;
  GSList *rules;

  GtkFileFilterFlags needed;
};

struct _FilterRule
{
  FilterRuleType type;
  GtkFileFilterFlags needed;
  
  union {
    gchar *pattern;
    gchar *mime_type;
119
    GSList *pixbuf_formats;
Owen Taylor's avatar
Owen Taylor committed
120 121 122 123 124 125 126 127 128 129 130
    struct {
      GtkFileFilterFunc func;
      gpointer data;
      GDestroyNotify notify;
    } custom;
  } u;
};

static void gtk_file_filter_finalize   (GObject            *object);


131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
static void     gtk_file_filter_buildable_init                 (GtkBuildableIface *iface);
static gboolean gtk_file_filter_buildable_custom_tag_start     (GtkBuildable  *buildable,
								GtkBuilder    *builder,
								GObject       *child,
								const gchar   *tagname,
								GMarkupParser *parser,
								gpointer      *data);
static void     gtk_file_filter_buildable_custom_tag_end       (GtkBuildable  *buildable,
								GtkBuilder    *builder,
								GObject       *child,
								const gchar   *tagname,
								gpointer      *data);

G_DEFINE_TYPE_WITH_CODE (GtkFileFilter, gtk_file_filter, G_TYPE_INITIALLY_UNOWNED,
                         G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
                                                gtk_file_filter_buildable_init))
Owen Taylor's avatar
Owen Taylor committed
147

148 149 150
static void
gtk_file_filter_init (GtkFileFilter *object)
{
Owen Taylor's avatar
Owen Taylor committed
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
}

static void
gtk_file_filter_class_init (GtkFileFilterClass *class)
{
  GObjectClass *gobject_class = G_OBJECT_CLASS (class);

  gobject_class->finalize = gtk_file_filter_finalize;
}

static void
filter_rule_free (FilterRule *rule)
{
  switch (rule->type)
    {
    case FILTER_RULE_MIME_TYPE:
      g_free (rule->u.mime_type);
      break;
    case FILTER_RULE_PATTERN:
      g_free (rule->u.pattern);
      break;
    case FILTER_RULE_CUSTOM:
      if (rule->u.custom.notify)
	rule->u.custom.notify (rule->u.custom.data);
      break;
176 177 178
    case FILTER_RULE_PIXBUF_FORMATS:
      g_slist_free (rule->u.pixbuf_formats);
      break;
179 180
    default:
      g_assert_not_reached ();
Owen Taylor's avatar
Owen Taylor committed
181 182
    }

Michael Natterer's avatar
Michael Natterer committed
183
  g_slice_free (FilterRule, rule);
Owen Taylor's avatar
Owen Taylor committed
184 185 186 187 188
}

static void
gtk_file_filter_finalize (GObject  *object)
{
189
  GtkFileFilter *filter = GTK_FILE_FILTER (object);
Owen Taylor's avatar
Owen Taylor committed
190 191

  g_slist_foreach (filter->rules, (GFunc)filter_rule_free, NULL);
192 193
  g_slist_free (filter->rules);

194
  g_free (filter->name);
Owen Taylor's avatar
Owen Taylor committed
195

196
  G_OBJECT_CLASS (gtk_file_filter_parent_class)->finalize (object);
Owen Taylor's avatar
Owen Taylor committed
197 198
}

199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347
/*
 * GtkBuildable implementation
 */
static void
gtk_file_filter_buildable_init (GtkBuildableIface *iface)
{
  iface->custom_tag_start = gtk_file_filter_buildable_custom_tag_start;
  iface->custom_tag_end = gtk_file_filter_buildable_custom_tag_end;
}

typedef enum {
  PARSE_MIME_TYPES,
  PARSE_PATTERNS
} ParserType;

typedef struct {
  GtkFileFilter *filter;
  ParserType     type;
  GString       *string;
  gboolean       parsing;
} SubParserData;

static void
parser_start_element (GMarkupParseContext *context,
		      const gchar         *element_name,
		      const gchar        **names,
		      const gchar        **values,
		      gpointer             user_data,
		      GError             **error)
{
  SubParserData *parser_data = (SubParserData*)user_data;

  if (strcmp (element_name, "mime-types") == 0)
    return;
  else if (strcmp (element_name, "mime-type") == 0)
    {
      parser_data->parsing = TRUE;
      return;
    }
  else if (strcmp (element_name, "patterns") == 0)
    return;
  else if (strcmp (element_name, "pattern") == 0)
    {
      parser_data->parsing = TRUE;
      return;
    }
  else
    g_warning ("Unsupported tag for GtkFileFilter: %s\n", element_name);
}

static void
parser_text_element (GMarkupParseContext *context,
		     const gchar         *text,
		     gsize                text_len,
		     gpointer             user_data,
		     GError             **error)
{
  SubParserData *parser_data = (SubParserData*)user_data;

  if (parser_data->parsing)
    g_string_append_len (parser_data->string, text, text_len);
}

static void
parser_end_element (GMarkupParseContext *context,
		    const gchar         *element_name,
		    gpointer             user_data,
		    GError             **error)
{
  SubParserData *parser_data = (SubParserData*)user_data;

  if (parser_data->string)
    {
      switch (parser_data->type)
	{
	case PARSE_MIME_TYPES:
	  gtk_file_filter_add_mime_type (parser_data->filter, parser_data->string->str);
	  break;
	case PARSE_PATTERNS:
	  gtk_file_filter_add_pattern (parser_data->filter, parser_data->string->str);
	  break;
	default:
	  break;
	}
    }

  g_string_set_size (parser_data->string, 0);
  parser_data->parsing = FALSE;
}

static const GMarkupParser sub_parser =
  {
    parser_start_element,
    parser_end_element,
    parser_text_element,
  };

static gboolean
gtk_file_filter_buildable_custom_tag_start (GtkBuildable  *buildable,
					      GtkBuilder    *builder,
					      GObject       *child,
					      const gchar   *tagname,
					      GMarkupParser *parser,
					      gpointer      *data)
{
  SubParserData *parser_data = NULL;

  if (strcmp (tagname, "mime-types") == 0)
    {
      parser_data         = g_slice_new0 (SubParserData);
      parser_data->string = g_string_new ("");
      parser_data->type   = PARSE_MIME_TYPES;
      parser_data->filter = GTK_FILE_FILTER (buildable);

      *parser = sub_parser;
      *data = parser_data;
    }
  else if (strcmp (tagname, "patterns") == 0)
    {
      parser_data         = g_slice_new0 (SubParserData);
      parser_data->string = g_string_new ("");
      parser_data->type   = PARSE_PATTERNS;
      parser_data->filter = GTK_FILE_FILTER (buildable);

      *parser = sub_parser;
      *data = parser_data;
    }

  return parser_data != NULL;
}

static void
gtk_file_filter_buildable_custom_tag_end (GtkBuildable *buildable,
					  GtkBuilder   *builder,
					  GObject      *child,
					  const gchar  *tagname,
					  gpointer     *data)
{
  if (strcmp (tagname, "mime-types") == 0 ||
      strcmp (tagname, "patterns") == 0)
    {
      SubParserData *parser_data = (SubParserData*)data;

      g_string_free (parser_data->string, TRUE);
      g_slice_free (SubParserData, parser_data);
    }
}


Owen Taylor's avatar
Owen Taylor committed
348 349 350 351 352 353 354 355 356
/**
 * gtk_file_filter_new:
 * 
 * Creates a new #GtkFileFilter with no rules added to it.
 * Such a filter doesn't accept any files, so is not
 * particularly useful until you add rules with
 * gtk_file_filter_add_mime_type(), gtk_file_filter_add_pattern(),
 * or gtk_file_filter_add_custom(). To create a filter
 * that accepts any file, use:
Matthias Clasen's avatar
Matthias Clasen committed
357 358
 * |[
 * GtkFileFilter *filter = gtk_file_filter_new ();
Owen Taylor's avatar
Owen Taylor committed
359
 * gtk_file_filter_add_pattern (filter, "*");
Matthias Clasen's avatar
Matthias Clasen committed
360
 * ]|
Owen Taylor's avatar
Owen Taylor committed
361 362
 * 
 * Return value: a new #GtkFileFilter
363 364
 * 
 * Since: 2.4
Owen Taylor's avatar
Owen Taylor committed
365 366 367 368 369 370 371 372 373 374
 **/
GtkFileFilter *
gtk_file_filter_new (void)
{
  return g_object_new (GTK_TYPE_FILE_FILTER, NULL);
}

/**
 * gtk_file_filter_set_name:
 * @filter: a #GtkFileFilter
375
 * @name: (allow-none): the human-readable-name for the filter, or %NULL
Owen Taylor's avatar
Owen Taylor committed
376 377 378 379 380
 *   to remove any existing name.
 * 
 * Sets the human-readable name of the filter; this is the string
 * that will be displayed in the file selector user interface if
 * there is a selectable list of filters.
381 382
 * 
 * Since: 2.4
Owen Taylor's avatar
Owen Taylor committed
383 384 385 386 387 388 389
 **/
void
gtk_file_filter_set_name (GtkFileFilter *filter,
			  const gchar   *name)
{
  g_return_if_fail (GTK_IS_FILE_FILTER (filter));
  
390
  g_free (filter->name);
Owen Taylor's avatar
Owen Taylor committed
391 392 393 394 395 396 397 398 399 400 401 402 403

  filter->name = g_strdup (name);
}

/**
 * gtk_file_filter_get_name:
 * @filter: a #GtkFileFilter
 * 
 * Gets the human-readable name for the filter. See gtk_file_filter_set_name().
 * 
 * Return value: The human-readable name of the filter,
 *   or %NULL. This value is owned by GTK+ and must not
 *   be modified or freed.
404 405
 * 
 * Since: 2.4
Owen Taylor's avatar
Owen Taylor committed
406
 **/
407
const gchar *
Owen Taylor's avatar
Owen Taylor committed
408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428
gtk_file_filter_get_name (GtkFileFilter *filter)
{
  g_return_val_if_fail (GTK_IS_FILE_FILTER (filter), NULL);
  
  return filter->name;
}

static void
file_filter_add_rule (GtkFileFilter *filter,
		      FilterRule    *rule)
{
  filter->needed |= rule->needed;
  filter->rules = g_slist_append (filter->rules, rule);
}

/**
 * gtk_file_filter_add_mime_type:
 * @filter: A #GtkFileFilter
 * @mime_type: name of a MIME type
 * 
 * Adds a rule allowing a given mime type to @filter.
429 430
 * 
 * Since: 2.4
Owen Taylor's avatar
Owen Taylor committed
431 432 433 434 435 436 437 438 439 440
 **/
void
gtk_file_filter_add_mime_type (GtkFileFilter *filter,
			       const gchar   *mime_type)
{
  FilterRule *rule;
  
  g_return_if_fail (GTK_IS_FILE_FILTER (filter));
  g_return_if_fail (mime_type != NULL);

Michael Natterer's avatar
Michael Natterer committed
441
  rule = g_slice_new (FilterRule);
Owen Taylor's avatar
Owen Taylor committed
442 443 444 445 446 447 448 449 450 451 452 453 454
  rule->type = FILTER_RULE_MIME_TYPE;
  rule->needed = GTK_FILE_FILTER_MIME_TYPE;
  rule->u.mime_type = g_strdup (mime_type);

  file_filter_add_rule (filter, rule);
}

/**
 * gtk_file_filter_add_pattern:
 * @filter: a #GtkFileFilter
 * @pattern: a shell style glob
 * 
 * Adds a rule allowing a shell style glob to a filter.
455 456
 * 
 * Since: 2.4
Owen Taylor's avatar
Owen Taylor committed
457 458 459 460 461 462 463 464 465 466
 **/
void
gtk_file_filter_add_pattern (GtkFileFilter *filter,
			     const gchar   *pattern)
{
  FilterRule *rule;
  
  g_return_if_fail (GTK_IS_FILE_FILTER (filter));
  g_return_if_fail (pattern != NULL);

Michael Natterer's avatar
Michael Natterer committed
467
  rule = g_slice_new (FilterRule);
Owen Taylor's avatar
Owen Taylor committed
468 469 470 471 472 473 474
  rule->type = FILTER_RULE_PATTERN;
  rule->needed = GTK_FILE_FILTER_DISPLAY_NAME;
  rule->u.pattern = g_strdup (pattern);

  file_filter_add_rule (filter, rule);
}

475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490
/**
 * gtk_file_filter_add_pixbuf_formats:
 * @filter: a #GtkFileFilter
 * 
 * Adds a rule allowing image files in the formats supported
 * by GdkPixbuf.
 * 
 * Since: 2.6
 **/
void
gtk_file_filter_add_pixbuf_formats (GtkFileFilter *filter)
{
  FilterRule *rule;
  
  g_return_if_fail (GTK_IS_FILE_FILTER (filter));

Michael Natterer's avatar
Michael Natterer committed
491
  rule = g_slice_new (FilterRule);
492 493 494 495 496 497 498
  rule->type = FILTER_RULE_PIXBUF_FORMATS;
  rule->needed = GTK_FILE_FILTER_MIME_TYPE;
  rule->u.pixbuf_formats = gdk_pixbuf_get_formats ();
  file_filter_add_rule (filter, rule);
}


Owen Taylor's avatar
Owen Taylor committed
499 500 501 502 503 504 505 506 507 508 509 510 511 512 513
/**
 * gtk_file_filter_add_custom:
 * @filter: a #GtkFileFilter
 * @needed: bitfield of flags indicating the information that the custom
 *          filter function needs.
 * @func: callback function; if the function returns %TRUE, then
 *   the file will be displayed.
 * @data: data to pass to @func
 * @notify: function to call to free @data when it is no longer needed.
 * 
 * Adds rule to a filter that allows files based on a custom callback
 * function. The bitfield @needed which is passed in provides information
 * about what sorts of information that the filter function needs;
 * this allows GTK+ to avoid retrieving expensive information when
 * it isn't needed by the filter.
514 515
 * 
 * Since: 2.4
Owen Taylor's avatar
Owen Taylor committed
516 517 518 519 520 521 522 523 524 525 526 527 528
 **/
void
gtk_file_filter_add_custom (GtkFileFilter         *filter,
			    GtkFileFilterFlags     needed,
			    GtkFileFilterFunc      func,
			    gpointer               data,
			    GDestroyNotify         notify)
{
  FilterRule *rule;
  
  g_return_if_fail (GTK_IS_FILE_FILTER (filter));
  g_return_if_fail (func != NULL);

Michael Natterer's avatar
Michael Natterer committed
529
  rule = g_slice_new (FilterRule);
Owen Taylor's avatar
Owen Taylor committed
530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551
  rule->type = FILTER_RULE_CUSTOM;
  rule->needed = needed;
  rule->u.custom.func = func;
  rule->u.custom.data = data;
  rule->u.custom.notify = notify;

  file_filter_add_rule (filter, rule);
}

/**
 * gtk_file_filter_get_needed:
 * @filter: a #GtkFileFilter
 * 
 * Gets the fields that need to be filled in for the structure
 * passed to gtk_file_filter_filter()
 * 
 * This function will not typically be used by applications; it
 * is intended principally for use in the implementation of
 * #GtkFileChooser.
 * 
 * Return value: bitfield of flags indicating needed fields when
 *   calling gtk_file_filter_filter()
552 553
 * 
 * Since: 2.4
Owen Taylor's avatar
Owen Taylor committed
554 555 556 557 558 559 560 561 562 563 564 565 566 567 568
 **/
GtkFileFilterFlags
gtk_file_filter_get_needed (GtkFileFilter *filter)
{
  return filter->needed;
}

/**
 * gtk_file_filter_filter:
 * @filter: a #GtkFileFilter
 * @filter_info: a #GtkFileFilterInfo structure containing information
 *  about a file.
 * 
 * Tests whether a file should be displayed according to @filter.
 * The #GtkFileFilterInfo structure @filter_info should include
Matthias Clasen's avatar
Matthias Clasen committed
569
 * the fields returned from gtk_file_filter_get_needed().
Owen Taylor's avatar
Owen Taylor committed
570 571 572 573 574 575
 *
 * This function will not typically be used by applications; it
 * is intended principally for use in the implementation of
 * #GtkFileChooser.
 * 
 * Return value: %TRUE if the file should be displayed
576 577
 * 
 * Since: 2.4
Owen Taylor's avatar
Owen Taylor committed
578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594
 **/
gboolean
gtk_file_filter_filter (GtkFileFilter           *filter,
			const GtkFileFilterInfo *filter_info)
{
  GSList *tmp_list;

  for (tmp_list = filter->rules; tmp_list; tmp_list = tmp_list->next)
    {
      FilterRule *rule = tmp_list->data;

      if ((filter_info->contains & rule->needed) != rule->needed)
	continue;
      
      switch (rule->type)
	{
	case FILTER_RULE_MIME_TYPE:
595 596
	  if (filter_info->mime_type != NULL &&
              g_content_type_is_a (filter_info->mime_type, rule->u.mime_type))
Owen Taylor's avatar
Owen Taylor committed
597 598 599
	    return TRUE;
	  break;
	case FILTER_RULE_PATTERN:
600
	  if (filter_info->display_name != NULL &&
Federico Mena Quintero's avatar
Federico Mena Quintero committed
601
	      _gtk_fnmatch (rule->u.pattern, filter_info->display_name, FALSE))
Owen Taylor's avatar
Owen Taylor committed
602 603
	    return TRUE;
	  break;
604 605 606 607
	case FILTER_RULE_PIXBUF_FORMATS:
	  {
	    GSList *list;

608 609 610
	    if (!filter_info->mime_type)
	      break;

611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630
	    for (list = rule->u.pixbuf_formats; list; list = list->next)
	      {
		int i;
		gchar **mime_types;

		mime_types = gdk_pixbuf_format_get_mime_types (list->data);

		for (i = 0; mime_types[i] != NULL; i++)
		  {
		    if (strcmp (mime_types[i], filter_info->mime_type) == 0)
		      {
			g_strfreev (mime_types);
			return TRUE;
		      }
		  }

		g_strfreev (mime_types);
	      }
	    break;
	  }
Owen Taylor's avatar
Owen Taylor committed
631 632 633 634 635 636 637 638 639
	case FILTER_RULE_CUSTOM:
	  if (rule->u.custom.func (filter_info, rule->u.custom.data))
	    return TRUE;
	  break;
	}
    }

  return FALSE;
}