~ubuntu-branches/ubuntu/precise/gtkmm3.0/precise

« back to all changes in this revision

Viewing changes to gtk/src/filefilter.hg

  • Committer: Bazaar Package Importer
  • Author(s): Michael Biebl
  • Date: 2011-06-17 00:12:44 UTC
  • Revision ID: james.westby@ubuntu.com-20110617001244-9hl5an15hiaaahi6
Tags: upstream-3.0.1
ImportĀ upstreamĀ versionĀ 3.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Id: filefilter.hg,v 1.8 2004/11/12 11:51:42 murrayc Exp $ */
 
2
 
 
3
/* Copyright (C) 2003 The gtkmm Development Team
 
4
 *
 
5
 * This library is free software; you can redistribute it and/or
 
6
 * modify it under the terms of the GNU Lesser General Public
 
7
 * License as published by the Free Software Foundation; either
 
8
 * version 2.1 of the License, or (at your option) any later version.
 
9
 *
 
10
 * This library is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
 * Lesser General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU Lesser General Public
 
16
 * License along with this library; if not, write to the Free
 
17
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
18
 */
 
19
 
 
20
#include <glibmm/object.h>
 
21
 
 
22
_DEFS(gtkmm,gtk)
 
23
_PINCLUDE(glibmm/private/object_p.h)
 
24
 
 
25
namespace Gtk
 
26
{
 
27
 
 
28
_WRAP_ENUM(FileFilterFlags, GtkFileFilterFlags)
 
29
 
 
30
/** A filter for selecting a file subset.
 
31
 *
 
32
 * A Gtk::FileFilter can be used to restrict the files being shown in a Gtk::FileChooser.
 
33
 * Files can be filtered based on their name (with add_pattern()),
 
34
 * on their mime type (with add_mime_type()), or by a custom filter
 
35
 * function (with add_custom()).
 
36
 *
 
37
 * Filtering by mime types handles aliasing and subclassing of mime types;
 
38
 * e.g. a filter for text/plain also matches a file with mime type application/rtf,
 
39
 * since application/rtf is a subclass of text/plain. Note that Gtk::FileFilter
 
40
 * allows wildcards for the subtype of a mime type, so you can e.g. filter for image/ *.
 
41
 *
 
42
 * Normally, filters are used by adding them to a Gtk::FileChooser. See Gtk::FileChooser::add_filter().
 
43
 * But it is also possible to manually use a filter on a file with filter().
 
44
 */
 
45
class FileFilter : public Glib::Object
 
46
{
 
47
  _CLASS_GOBJECT(FileFilter, GtkFileFilter, GTK_FILE_FILTER, Glib::Object, GObject)
 
48
  _DERIVES_INITIALLY_UNOWNED()
 
49
protected:
 
50
  _CTOR_DEFAULT
 
51
 
 
52
public:
 
53
  _WRAP_CREATE()
 
54
 
 
55
  _WRAP_METHOD(void set_name(const Glib::ustring& name), gtk_file_filter_set_name)
 
56
  _WRAP_METHOD(Glib::ustring get_name() const, gtk_file_filter_get_name)
 
57
 
 
58
  _WRAP_METHOD(void add_mime_type(const Glib::ustring& mime_type), gtk_file_filter_add_mime_type)
 
59
  _WRAP_METHOD(void add_pattern(const Glib::ustring& pattern), gtk_file_filter_add_pattern)
 
60
  _WRAP_METHOD(void add_pixbuf_formats(), gtk_file_filter_add_pixbuf_formats)
 
61
 
 
62
  class Info
 
63
  {
 
64
  public:
 
65
    FileFilterFlags contains;
 
66
    Glib::ustring filename;
 
67
    Glib::ustring uri;
 
68
    Glib::ustring display_name;
 
69
    Glib::ustring mime_type;
 
70
  };
 
71
 
 
72
  /// For instance, bool on_custom(const Gtk::FileFilter::Info& filter_info);
 
73
  typedef sigc::slot<bool, const Info&> SlotCustom;
 
74
 
 
75
  void add_custom(FileFilterFlags needed, const SlotCustom& slot);
 
76
  _IGNORE(gtk_file_filter_add_custom)
 
77
 
 
78
  _WRAP_METHOD(FileFilterFlags get_needed() const, gtk_file_filter_get_needed)
 
79
 
 
80
  //TODO: This method is only used by FileChooser implementors, so we don't need to wrap it.
 
81
  _IGNORE(gtk_file_filter_filter)
 
82
  //_WRAP_METHOD(bool filter(const GtkFileFilterInfo* filter_info), gtk_file_filter_filter)
 
83
};
 
84
 
 
85
} // namespace Gtk