gtk/auto/recent_filter.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{Buildable, RecentFilterFlags, ffi};
6use glib::translate::*;
7
8glib::wrapper! {
9 ///
10 /// ]|
11 ///
12 /// # Implements
13 ///
14 /// [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual]
15 #[doc(alias = "GtkRecentFilter")]
16 pub struct RecentFilter(Object<ffi::GtkRecentFilter>) @implements Buildable;
17
18 match fn {
19 type_ => || ffi::gtk_recent_filter_get_type(),
20 }
21}
22
23impl RecentFilter {
24 ///
25 /// GtkRecentFilter *filter = gtk_recent_filter_new ();
26 /// gtk_recent_filter_add_pattern (filter, "*");
27 /// ]|
28 ///
29 /// # Returns
30 ///
31 /// a new [`RecentFilter`][crate::RecentFilter]
32 #[doc(alias = "gtk_recent_filter_new")]
33 pub fn new() -> RecentFilter {
34 assert_initialized_main_thread!();
35 unsafe { from_glib_none(ffi::gtk_recent_filter_new()) }
36 }
37
38 /// Adds a rule that allows resources based on their age - that is, the number
39 /// of days elapsed since they were last modified.
40 /// ## `days`
41 /// number of days
42 #[doc(alias = "gtk_recent_filter_add_age")]
43 pub fn add_age(&self, days: i32) {
44 unsafe {
45 ffi::gtk_recent_filter_add_age(self.to_glib_none().0, days);
46 }
47 }
48
49 /// Adds a rule that allows resources based on the name of the application
50 /// that has registered them.
51 /// ## `application`
52 /// an application name
53 #[doc(alias = "gtk_recent_filter_add_application")]
54 pub fn add_application(&self, application: &str) {
55 unsafe {
56 ffi::gtk_recent_filter_add_application(
57 self.to_glib_none().0,
58 application.to_glib_none().0,
59 );
60 }
61 }
62
63 //#[doc(alias = "gtk_recent_filter_add_custom")]
64 //pub fn add_custom(&self, needed: RecentFilterFlags, func: /*Unimplemented*/Fn(/*Ignored*/RecentFilterInfo) -> bool, data: /*Unimplemented*/Option<Basic: Pointer>) {
65 // unsafe { TODO: call ffi:gtk_recent_filter_add_custom() }
66 //}
67
68 /// Adds a rule that allows resources based on the name of the group
69 /// to which they belong
70 /// ## `group`
71 /// a group name
72 #[doc(alias = "gtk_recent_filter_add_group")]
73 pub fn add_group(&self, group: &str) {
74 unsafe {
75 ffi::gtk_recent_filter_add_group(self.to_glib_none().0, group.to_glib_none().0);
76 }
77 }
78
79 /// Adds a rule that allows resources based on their registered MIME type.
80 /// ## `mime_type`
81 /// a MIME type
82 #[doc(alias = "gtk_recent_filter_add_mime_type")]
83 pub fn add_mime_type(&self, mime_type: &str) {
84 unsafe {
85 ffi::gtk_recent_filter_add_mime_type(self.to_glib_none().0, mime_type.to_glib_none().0);
86 }
87 }
88
89 /// Adds a rule that allows resources based on a pattern matching their
90 /// display name.
91 /// ## `pattern`
92 /// a file pattern
93 #[doc(alias = "gtk_recent_filter_add_pattern")]
94 pub fn add_pattern(&self, pattern: &str) {
95 unsafe {
96 ffi::gtk_recent_filter_add_pattern(self.to_glib_none().0, pattern.to_glib_none().0);
97 }
98 }
99
100 /// Adds a rule allowing image files in the formats supported
101 /// by GdkPixbuf.
102 #[doc(alias = "gtk_recent_filter_add_pixbuf_formats")]
103 pub fn add_pixbuf_formats(&self) {
104 unsafe {
105 ffi::gtk_recent_filter_add_pixbuf_formats(self.to_glib_none().0);
106 }
107 }
108
109 /// Gets the human-readable name for the filter.
110 /// See [`set_name()`][Self::set_name()].
111 ///
112 /// # Returns
113 ///
114 /// the name of the filter, or [`None`]. The returned string
115 /// is owned by the filter object and should not be freed.
116 #[doc(alias = "gtk_recent_filter_get_name")]
117 #[doc(alias = "get_name")]
118 pub fn name(&self) -> Option<glib::GString> {
119 unsafe { from_glib_none(ffi::gtk_recent_filter_get_name(self.to_glib_none().0)) }
120 }
121
122 /// Gets the fields that need to be filled in for the `GtkRecentFilterInfo`
123 /// passed to `gtk_recent_filter_filter()`
124 ///
125 /// This function will not typically be used by applications; it
126 /// is intended principally for use in the implementation of
127 /// [`RecentChooser`][crate::RecentChooser].
128 ///
129 /// # Returns
130 ///
131 /// bitfield of flags indicating needed fields when
132 /// calling `gtk_recent_filter_filter()`
133 #[doc(alias = "gtk_recent_filter_get_needed")]
134 #[doc(alias = "get_needed")]
135 pub fn needed(&self) -> RecentFilterFlags {
136 unsafe { from_glib(ffi::gtk_recent_filter_get_needed(self.to_glib_none().0)) }
137 }
138
139 /// Sets the human-readable name of the filter; this is the string
140 /// that will be displayed in the recently used resources selector
141 /// user interface if there is a selectable list of filters.
142 /// ## `name`
143 /// then human readable name of `self`
144 #[doc(alias = "gtk_recent_filter_set_name")]
145 pub fn set_name(&self, name: &str) {
146 unsafe {
147 ffi::gtk_recent_filter_set_name(self.to_glib_none().0, name.to_glib_none().0);
148 }
149 }
150}
151
152impl Default for RecentFilter {
153 fn default() -> Self {
154 Self::new()
155 }
156}