Xfce Foundation Classes
Main Page | Index | Namespace List | Alphabetical List | Class List | File List

# Xfc::Gtk::FileFilter Class Reference

A GtkFileFilter C++ wrapper class. More...

`#include <xfc/gtk/filefilter.hh>`

Inheritance diagram for Xfc::Gtk::FileFilter:

List of all members.

## Public Types

- typedef sigc::slot< bool,
  const FileFilterInfo & > CustomSlot
    Signature of the custom filter callback slot to be called to filter files.

## Public Member Functions

Constructors

- FileFilter ()
    Constructs a new file filter with no rules added to it.
- virtual ~FileFilter ()
    Destructor.

Accessors

- GtkFileFilter * gtk_file_filter () const
    Get a pointer to the GtkFileFilter structure.
- operator GtkFileFilter * () const
    Conversion operator; safely converts an FileFilter to a GtkFileFilter pointer.
- String get_name () const
    Gets the human-readable name for the filter (see set_name()).

Methods

- void set_name (const String &name)
    Sets the human-readable name of the filter.
- void add_mime_type (const String &mime_type)
    Adds a rule allowing a given mime type to filter.
- void add_pattern (const String &pattern)
    Adds a rule allowing a shell style glob to filter.
- void add_pixbuf_formats ()
    Adds a rule allowing image files in the formats supported by Gdk::Pixbuf.
- void add_custom (FileFilterFlagsField needed, const CustomSlot &slot)
    Adds rule to the filter that allows files based on a custom callback slot.

## Protected Member Functions

Constructors

- FileFilter (GtkFileFilter *filter, bool owns_reference=false)
    Construct a new FileFilter from an existing GtkFileFilter.

## Detailed Description

A GtkFileFilter C++ wrapper class.

FileFilter is a filter for selecting a file subset.

## Member Typedef Documentation

typedef sigc::slot<bool, const FileFilterInfo&> Xfc::Gtk::FileFilter::CustomSlot

Signature of the custom filter callback slot to be called to filter files.

Example: Method signature for CustomSlot.

                 bool method(const FileFilterInfo& filter_info);
                 // filter_info: The file information as requested when the slot was added.

## Constructor & Destructor Documentation

Xfc::Gtk::FileFilter::FileFilter | ( | GtkFileFilter * | filter,
|  | bool | owns_reference = `false`
| ) | `[explicit, protected]`

Construct a new FileFilter from an existing GtkFileFilter.

Parameters:

  | filter | A pointer to a GtkFileFilter.
  | owns_reference | Set false if the initial reference count is floating, set true if it's not.

The filter can be a newly created GtkFileFilter or an existing GtkFileFilter (see G::Object::Object).

Xfc::Gtk::FileFilter::FileFilter | ( |  | ) |

Constructs a new file filter with no rules added to it.

Such a filter doesn't accept any files, so is not particularly useful until you add rules with add_mime_type(), add_pattern(), or add_custom().

Example: To create a filter that accepts any file, use:

                 Gtk::FileFilter *filter = new Gtk::FileFilter;
                 filter->add_pattern("*");

## Member Function Documentation

void Xfc::Gtk::FileFilter::add_custom | ( | FileFilterFlagsField | needed,
|  | const CustomSlot & | slot
| ) |

Adds rule to the filter that allows files based on a custom callback slot.

Parameters:

  | needed | The bitfield of Gtk::FileFilterFlags indicating the information that the custom filter slot needs.
  | slot | The callback slot; if the slot returns true, then the file will be displayed.

The bitfield needed which is passed in provides information about what sorts of information the filter function needs; this allows GTK+ to avoid retrieving expensive information when it isn't needed by the filter.

void Xfc::Gtk::FileFilter::add_mime_type | ( | const String & | mime_type | ) |

Adds a rule allowing a given mime type to filter.

Parameters:

  | mime_type | The name of a MIME type (such as "image/png").

void Xfc::Gtk::FileFilter::add_pattern | ( | const String & | pattern | ) |

Adds a rule allowing a shell style glob to filter.

Parameters:

  | pattern | A shell style glob (such as "*" for all files).

String Xfc::Gtk::FileFilter::get_name | ( |  | ) | const

Gets the human-readable name for the filter (see set_name()).

Returns:
  The human-readable name of the filter, or a null String.

void Xfc::Gtk::FileFilter::set_name | ( | const String & | name | ) |

Sets the human-readable name of the filter.

Parameters:

  | name | The human-readable-name for the filter, or null to remove any existing name.

This is the string that will be displayed in the file selector user interface if there is a selectable list of filters.

Parameters:

  | name | The human-readable-name for the filter, or null to remove any existing name.

The documentation for this class was generated from the following file:

- filefilter.hh

Xfce Foundation Classes

Copyright © 2004-2005 The XFC Development Team | XFC 4.3