gtkmm 4.10.0
Public Member Functions | Static Public Member Functions | Protected Member Functions | Related Functions | List of all members
Gtk::FileFilter Class Reference

A filter for selecting a file subset. More...

#include <gtkmm/filefilter.h>

Inheritance diagram for Gtk::FileFilter:
Inheritance graph
[legend]

Public Member Functions

 FileFilter (FileFilter && src) noexcept
 
FileFilteroperator= (FileFilter && src) noexcept
 
 ~FileFilter () noexcept override
 
GtkFileFilter * gobj ()
 Provides access to the underlying C GObject.
 
const GtkFileFilter * gobj () const
 Provides access to the underlying C GObject.
 
GtkFileFilter * gobj_copy ()
 Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
 
void set_name (const Glib::ustring & name)
 Sets a human-readable name of the filter.
 
Glib::ustring get_name () const
 Gets the human-readable name for the filter.
 
void add_mime_type (const Glib::ustring & mime_type)
 Adds a rule allowing a given mime type to filter.
 
void add_pattern (const Glib::ustring & pattern)
 Adds a rule allowing a shell style glob to a filter.
 
void add_suffix (const std::string & suffix)
 Adds a suffix match rule to a filter.
 
void add_pixbuf_formats ()
 Adds a rule allowing image files in the formats supported by GdkPixbuf.
 
Glib::PropertyProxy< Glib::ustringproperty_name ()
 The human-readable name of the filter.
 
Glib::PropertyProxy_ReadOnly< Glib::ustringproperty_name () const
 The human-readable name of the filter.
 
- Public Member Functions inherited from Gtk::Filter
 Filter (Filter && src) noexcept
 
Filteroperator= (Filter && src) noexcept
 
 ~Filter () noexcept override
 
GtkFilter * gobj ()
 Provides access to the underlying C GObject.
 
const GtkFilter * gobj () const
 Provides access to the underlying C GObject.
 
GtkFilter * gobj_copy ()
 Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
 
bool match (const Glib::RefPtr< Glib::ObjectBase > & item)
 Checks if the given item is matched by the filter or not.
 
Match get_strictness ()
 Gets the known strictness of filters.
 
Glib::SignalProxy< void(Change)> signal_changed ()
 
- Public Member Functions inherited from Glib::Object
 Object (const Object &)=delete
 
Objectoperator= (const Object &)=delete
 
 Object (Object &&src) noexcept
 
Objectoperator= (Object &&src) noexcept
 
void * get_data (const QueryQuark &key)
 
void set_data (const Quark &key, void *data)
 
void set_data (const Quark &key, void *data, DestroyNotify notify)
 
void remove_data (const QueryQuark &quark)
 
void * steal_data (const QueryQuark &quark)
 
Glib::RefPtr< Glib::Objectwrap (GObject *object, bool take_copy=false)
 
- Public Member Functions inherited from Glib::ObjectBase
 ObjectBase (const ObjectBase &)=delete
 
ObjectBaseoperator= (const ObjectBase &)=delete
 
void set_property_value (const Glib::ustring &property_name, const Glib::ValueBase &value)
 
void get_property_value (const Glib::ustring &property_name, Glib::ValueBase &value) const
 
void set_property (const Glib::ustring &property_name, const PropertyType &value)
 
void get_property (const Glib::ustring &property_name, PropertyType &value) const
 
PropertyType get_property (const Glib::ustring &property_name) const
 
sigc::connection connect_property_changed (const Glib::ustring &property_name, const sigc::slot< void()> &slot)
 
sigc::connection connect_property_changed (const Glib::ustring &property_name, sigc::slot< void()> &&slot)
 
void freeze_notify ()
 
void thaw_notify ()
 
virtual void reference () const
 
virtual void unreference () const
 
GObject * gobj ()
 
const GObject * gobj () const
 
GObject * gobj_copy () const
 
- Public Member Functions inherited from Gtk::Buildable
 Buildable (Buildable && src) noexcept
 
Buildableoperator= (Buildable && src) noexcept
 
 ~Buildable () noexcept override
 
GtkBuildable * gobj ()
 Provides access to the underlying C GObject.
 
const GtkBuildable * gobj () const
 Provides access to the underlying C GObject.
 
Glib::ustring get_buildable_id () const
 Gets the ID of the buildable object.
 
- Public Member Functions inherited from Glib::Interface
 Interface ()
 
 Interface (Interface &&src) noexcept
 
Interfaceoperator= (Interface &&src) noexcept
 
 Interface (const Glib::Interface_Class &interface_class)
 
 Interface (GObject *castitem)
 
 ~Interface () noexcept override
 
 Interface (const Interface &)=delete
 
Interfaceoperator= (const Interface &)=delete
 
GObject * gobj ()
 
const GObject * gobj () const
 

Static Public Member Functions

static GType get_type ()
 Get the GType for this class, for use with the underlying GObject type system.
 
static Glib::RefPtr< FileFiltercreate ()
 
- Static Public Member Functions inherited from Gtk::Filter
static GType get_type ()
 Get the GType for this class, for use with the underlying GObject type system.
 
- Static Public Member Functions inherited from Gtk::Buildable
static void add_interface (GType gtype_implementer)
 
static GType get_type ()
 Get the GType for this class, for use with the underlying GObject type system.
 

Protected Member Functions

 FileFilter ()
 
- Protected Member Functions inherited from Gtk::Filter
 Filter ()
 
void changed (Change change=Change::DIFFERENT)
 Notifies all users of the filter that it has changed.
 
virtual bool match_vfunc (const Glib::RefPtr< Glib::ObjectBase > & item)
 
virtual Match get_strictness_vfunc ()
 
- Protected Member Functions inherited from Glib::Object
 Object ()
 
 Object (const Glib::ConstructParams &construct_params)
 
 Object (GObject *castitem)
 
 ~Object () noexcept override
 
- Protected Member Functions inherited from Glib::ObjectBase
 ObjectBase ()
 
 ObjectBase (const char *custom_type_name)
 
 ObjectBase (const std::type_info &custom_type_info)
 
 ObjectBase (ObjectBase &&src) noexcept
 
ObjectBaseoperator= (ObjectBase &&src) noexcept
 
virtual ~ObjectBase () noexcept=0
 
void initialize (GObject *castitem)
 
void initialize_move (GObject *castitem, Glib::ObjectBase *previous_wrapper)
 
- Protected Member Functions inherited from Gtk::Buildable
 Buildable ()
 You should derive from this class to use it.
 

Related Functions

(Note that these are not member functions.)

Glib::RefPtr< Gtk::FileFilterwrap (GtkFileFilter * object, bool take_copy=false)
 A Glib::wrap() method for this object.
 

Additional Inherited Members

- Public Types inherited from Gtk::Filter
enum class  Match {
  Match::SOME ,
  Match::NONE ,
  Match::ALL
}
 Describes the known strictness of a filter. More...
 
enum class  Change {
  Change::DIFFERENT ,
  Change::LESS_STRICT ,
  Change::MORE_STRICT
}
 Describes changes in a filter in more detail and allows objects using the filter to optimize refiltering items. More...
 
- Public Types inherited from Glib::Object
typedef void(*)(gpointer data DestroyNotify)
 

Detailed Description

A filter for selecting a file subset.

A Gtk::FileFilter can be used to restrict the files being shown in a Gtk::FileChooser. Files can be filtered based on their name (with add_pattern()), on their MIME type (with add_mime_type()), or by a custom filter function (with 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 Gtk::FileFilter allows wildcards for the subtype of a MIME type, so you can e.g. filter for image/ *.

Filters are used by adding them to a Gtk::FileChooser. See Gtk::FileChooser::add_filter().

Constructor & Destructor Documentation

◆ FileFilter() [1/2]

Gtk::FileFilter::FileFilter ( FileFilter &&  src)
noexcept

◆ ~FileFilter()

Gtk::FileFilter::~FileFilter ( )
overridenoexcept

◆ FileFilter() [2/2]

Gtk::FileFilter::FileFilter ( )
protected

Member Function Documentation

◆ add_mime_type()

void Gtk::FileFilter::add_mime_type ( const Glib::ustring mime_type)

Adds a rule allowing a given mime type to filter.

Parameters
mime_typeName of a MIME type.

◆ add_pattern()

void Gtk::FileFilter::add_pattern ( const Glib::ustring pattern)

Adds a rule allowing a shell style glob to a filter.

Note that it depends on the platform whether pattern matching ignores case or not. On Windows, it does, on other platforms, it doesn't.

Parameters
patternA shell style glob.

◆ add_pixbuf_formats()

void Gtk::FileFilter::add_pixbuf_formats ( )

Adds a rule allowing image files in the formats supported by GdkPixbuf.

This is equivalent to calling add_mime_type() for all the supported mime types.

◆ add_suffix()

void Gtk::FileFilter::add_suffix ( const std::string suffix)

Adds a suffix match rule to a filter.

This is similar to adding a match for the pattern "*. @a suffix".

In contrast to pattern matches, suffix matches are always case-insensitive.

Since gtkmm 4.4:
Parameters
suffixFilename suffix to match.

◆ create()

static Glib::RefPtr< FileFilter > Gtk::FileFilter::create ( )
static

◆ get_name()

Glib::ustring Gtk::FileFilter::get_name ( ) const

Gets the human-readable name for the filter.

See set_name().

Returns
The human-readable name of the filter.

◆ get_type()

static GType Gtk::FileFilter::get_type ( )
static

Get the GType for this class, for use with the underlying GObject type system.

◆ gobj() [1/2]

GtkFileFilter * Gtk::FileFilter::gobj ( )
inline

Provides access to the underlying C GObject.

◆ gobj() [2/2]

const GtkFileFilter * Gtk::FileFilter::gobj ( ) const
inline

Provides access to the underlying C GObject.

◆ gobj_copy()

GtkFileFilter * Gtk::FileFilter::gobj_copy ( )

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

◆ operator=()

FileFilter & Gtk::FileFilter::operator= ( FileFilter &&  src)
noexcept

◆ property_name() [1/2]

Glib::PropertyProxy< Glib::ustring > Gtk::FileFilter::property_name ( )

The human-readable name of the filter.

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

Default value: ""

Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

◆ property_name() [2/2]

Glib::PropertyProxy_ReadOnly< Glib::ustring > Gtk::FileFilter::property_name ( ) const

The human-readable name of the filter.

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

Default value: ""

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ set_name()

void Gtk::FileFilter::set_name ( const Glib::ustring name)

Sets a human-readable name of the filter.

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

Parameters
nameThe human-readable-name for the filter, or nullptr to remove any existing name.

Friends And Related Function Documentation

◆ wrap()

Glib::RefPtr< Gtk::FileFilter > wrap ( GtkFileFilter *  object,
bool  take_copy = false 
)
related

A Glib::wrap() method for this object.

Parameters
objectThe C instance.
take_copyFalse if the result should take ownership of the C instance. True if it should take a new copy or ref.
Returns
A C++ instance that wraps this C instance.