v0.2.1 c0399be

gtkfilefilter.go RawHistoryFolder

1// Package gtk was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gtk
3
4import (
5	"unsafe"
6
7	"github.com/ebitengine/purego"
8
9	"github.com/bnema/puregotk/pkg/core"
10	"github.com/bnema/puregotk/v4/glib"
11	"github.com/bnema/puregotk/v4/gobject"
12	"github.com/bnema/puregotk/v4/gobject/types"
13)
14
15// Filters files by name or mime type.
16//
17// `GtkFileFilter` can be used to restrict the files being shown in a
18// file chooser. Files can be filtered based on their name (with
19// [method@Gtk.FileFilter.add_pattern] or [method@Gtk.FileFilter.add_suffix])
20// or on their mime type (with [method@Gtk.FileFilter.add_mime_type]).
21//
22// Filtering by mime types handles aliasing and subclassing of mime
23// types; e.g. a filter for text/plain also matches a file with mime
24// type application/rtf, since application/rtf is a subclass of
25// text/plain. Note that `GtkFileFilter` allows wildcards for the
26// subtype of a mime type, so you can e.g. filter for image/\*.
27//
28// Normally, file filters are used by adding them to a file chooser
29// (see [method@Gtk.FileDialog.set_filters]), but it is also possible to
30// manually use a file filter on any [class@Gtk.FilterListModel] containing
31// `GFileInfo` objects.
32//
33// # GtkFileFilter as GtkBuildable
34//
35// The `GtkFileFilter` implementation of the `GtkBuildable` interface
36// supports adding rules using the `<mime-types>` and `<patterns>` and
37// `<suffixes>` elements and listing the rules within. Specifying a
38// `<mime-type>` or `<pattern>` or `<suffix>` has the same effect as
39// as calling
40// [method@Gtk.FileFilter.add_mime_type] or
41// [method@Gtk.FileFilter.add_pattern] or
42// [method@Gtk.FileFilter.add_suffix].
43//
44// An example of a UI definition fragment specifying `GtkFileFilter`
45// rules:
46// ```xml
47// <object class="GtkFileFilter">
48//
49//	<property name="name" translatable="yes">Text and Images</property>
50//	<mime-types>
51//	  <mime-type>text/plain</mime-type>
52//	  <mime-type>image/ *</mime-type>
53//	</mime-types>
54//	<patterns>
55//	  <pattern>*.txt</pattern>
56//	</patterns>
57//	<suffixes>
58//	  <suffix>png</suffix>
59//	</suffixes>
60//
61// </object>
62// ```
63type FileFilter struct {
64	Filter
65}
66
67var xFileFilterGLibType func() types.GType
68
69func FileFilterGLibType() types.GType {
70	return xFileFilterGLibType()
71}
72
73func FileFilterNewFromInternalPtr(ptr uintptr) *FileFilter {
74	cls := &FileFilter{}
75	cls.Ptr = ptr
76	return cls
77}
78
79var xNewFileFilter func() uintptr
80
81// Creates a new `GtkFileFilter` with no rules added to it.
82//
83// Such a filter doesn’t accept any files, so is not
84// particularly useful until you add rules with
85// [method@Gtk.FileFilter.add_mime_type],
86// [method@Gtk.FileFilter.add_pattern],
87// [method@Gtk.FileFilter.add_suffix] or
88// [method@Gtk.FileFilter.add_pixbuf_formats].
89//
90// To create a filter that accepts any file, use:
91// ```c
92// GtkFileFilter *filter = gtk_file_filter_new ();
93// gtk_file_filter_add_pattern (filter, "*");
94// ```
95func NewFileFilter() *FileFilter {
96	var cls *FileFilter
97
98	cret := xNewFileFilter()
99
100	if cret == 0 {
101		return nil
102	}
103	cls = &FileFilter{}
104	cls.Ptr = cret
105	return cls
106}
107
108var xNewFileFilterFromGvariant func(*glib.Variant) uintptr
109
110// Deserialize a file filter from a `GVariant`.
111//
112// The variant must be in the format produced by
113// [method@Gtk.FileFilter.to_gvariant].
114func NewFileFilterFromGvariant(VariantVar *glib.Variant) *FileFilter {
115	var cls *FileFilter
116
117	cret := xNewFileFilterFromGvariant(VariantVar)
118
119	if cret == 0 {
120		return nil
121	}
122	cls = &FileFilter{}
123	cls.Ptr = cret
124	return cls
125}
126
127var xFileFilterAddMimeType func(uintptr, string)
128
129// Adds a rule allowing a given mime type.
130func (x *FileFilter) AddMimeType(MimeTypeVar string) {
131
132	xFileFilterAddMimeType(x.GoPointer(), MimeTypeVar)
133
134}
135
136var xFileFilterAddPattern func(uintptr, string)
137
138// Adds a rule allowing a shell style glob pattern.
139//
140// Note that it depends on the platform whether pattern
141// matching ignores case or not. On Windows, it does, on
142// other platforms, it doesn't.
143func (x *FileFilter) AddPattern(PatternVar string) {
144
145	xFileFilterAddPattern(x.GoPointer(), PatternVar)
146
147}
148
149var xFileFilterAddPixbufFormats func(uintptr)
150
151// Adds a rule allowing image files in the formats supported by `GdkPixbuf`.
152//
153// This is equivalent to calling [method@Gtk.FileFilter.add_mime_type]
154// for all the supported mime types.
155func (x *FileFilter) AddPixbufFormats() {
156
157	xFileFilterAddPixbufFormats(x.GoPointer())
158
159}
160
161var xFileFilterAddSuffix func(uintptr, string)
162
163// Adds a suffix match rule to a filter.
164//
165// This is similar to adding a match for the pattern "*.@suffix"
166//
167// An exaple to filter files with the suffix ".sub":
168// ```c
169// gtk_file_filter_add_suffix (filter, "sub");
170// ```
171//
172// Filters with multiple dots are allowed.
173//
174// In contrast to pattern matches, suffix matches
175// are *always* case-insensitive.
176func (x *FileFilter) AddSuffix(SuffixVar string) {
177
178	xFileFilterAddSuffix(x.GoPointer(), SuffixVar)
179
180}
181
182var xFileFilterGetAttributes func(uintptr) []string
183
184// Gets the attributes that need to be filled in for the `GFileInfo`
185// passed to this filter.
186//
187// This function will not typically be used by applications;
188// it is intended for use in file chooser implementation.
189func (x *FileFilter) GetAttributes() []string {
190
191	cret := xFileFilterGetAttributes(x.GoPointer())
192	return cret
193}
194
195var xFileFilterGetName func(uintptr) string
196
197// Gets the human-readable name for the filter.
198//
199// See [method@Gtk.FileFilter.set_name].
200func (x *FileFilter) GetName() string {
201
202	cret := xFileFilterGetName(x.GoPointer())
203	return cret
204}
205
206var xFileFilterSetName func(uintptr, uintptr)
207
208// Sets a human-readable name of the filter.
209//
210// This is the string that will be displayed in the user interface
211// if there is a selectable list of filters.
212func (x *FileFilter) SetName(NameVar *string) {
213
214	NameVarPtr := core.GStrdupNullable(NameVar)
215	defer core.GFreeNullable(NameVarPtr)
216
217	xFileFilterSetName(x.GoPointer(), NameVarPtr)
218
219}
220
221var xFileFilterToGvariant func(uintptr) *glib.Variant
222
223// Serialize a file filter to an `a{sv}` variant.
224func (x *FileFilter) ToGvariant() *glib.Variant {
225
226	cret := xFileFilterToGvariant(x.GoPointer())
227	return cret
228}
229
230func (c *FileFilter) GoPointer() uintptr {
231	if c == nil {
232		return 0
233	}
234	return c.Ptr
235}
236
237func (c *FileFilter) SetGoPointer(ptr uintptr) {
238	c.Ptr = ptr
239}
240
241// SetPropertyMimeTypes sets the "mime-types" property.
242// The MIME types that this filter matches.
243func (x *FileFilter) SetPropertyMimeTypes(value []string) {
244	var v gobject.Value
245	v.Init(glib.StrvGetType())
246	v.SetBoxed(uintptr(unsafe.Pointer(core.ByteSlice(value))))
247	x.SetProperty("mime-types", &v)
248}
249
250// SetPropertyName sets the "name" property.
251// The human-readable name of the filter.
252//
253// This is the string that will be displayed in the user interface
254// if there is a selectable list of filters.
255func (x *FileFilter) SetPropertyName(value string) {
256	var v gobject.Value
257	v.Init(gobject.TypeStringVal)
258	v.SetString(&value)
259	x.SetProperty("name", &v)
260}
261
262// GetPropertyName gets the "name" property.
263// The human-readable name of the filter.
264//
265// This is the string that will be displayed in the user interface
266// if there is a selectable list of filters.
267func (x *FileFilter) GetPropertyName() string {
268	var v gobject.Value
269	x.GetProperty("name", &v)
270	return v.GetString()
271}
272
273// SetPropertyPatterns sets the "patterns" property.
274// The patterns that this filter matches.
275func (x *FileFilter) SetPropertyPatterns(value []string) {
276	var v gobject.Value
277	v.Init(glib.StrvGetType())
278	v.SetBoxed(uintptr(unsafe.Pointer(core.ByteSlice(value))))
279	x.SetProperty("patterns", &v)
280}
281
282// SetPropertySuffixes sets the "suffixes" property.
283// The suffixes that this filter matches.
284func (x *FileFilter) SetPropertySuffixes(value []string) {
285	var v gobject.Value
286	v.Init(glib.StrvGetType())
287	v.SetBoxed(uintptr(unsafe.Pointer(core.ByteSlice(value))))
288	x.SetProperty("suffixes", &v)
289}
290
291// Gets the ID of the @buildable object.
292//
293// `GtkBuilder` sets the name based on the ID attribute
294// of the `<object>` tag used to construct the @buildable.
295func (x *FileFilter) GetBuildableId() string {
296
297	cret := XGtkBuildableGetBuildableId(x.GoPointer())
298	return cret
299}
300
301func init() {
302	core.SetPackageName("GTK", "gtk4")
303	core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
304	var libs []uintptr
305	for _, libPath := range core.GetPaths("GTK") {
306		lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
307		if err != nil {
308			panic(err)
309		}
310		libs = append(libs, lib)
311	}
312
313	core.PuregoSafeRegister(&xFileFilterGLibType, libs, "gtk_file_filter_get_type")
314
315	core.PuregoSafeRegister(&xNewFileFilter, libs, "gtk_file_filter_new")
316	core.PuregoSafeRegister(&xNewFileFilterFromGvariant, libs, "gtk_file_filter_new_from_gvariant")
317
318	core.PuregoSafeRegister(&xFileFilterAddMimeType, libs, "gtk_file_filter_add_mime_type")
319	core.PuregoSafeRegister(&xFileFilterAddPattern, libs, "gtk_file_filter_add_pattern")
320	core.PuregoSafeRegister(&xFileFilterAddPixbufFormats, libs, "gtk_file_filter_add_pixbuf_formats")
321	core.PuregoSafeRegister(&xFileFilterAddSuffix, libs, "gtk_file_filter_add_suffix")
322	core.PuregoSafeRegister(&xFileFilterGetAttributes, libs, "gtk_file_filter_get_attributes")
323	core.PuregoSafeRegister(&xFileFilterGetName, libs, "gtk_file_filter_get_name")
324	core.PuregoSafeRegister(&xFileFilterSetName, libs, "gtk_file_filter_set_name")
325	core.PuregoSafeRegister(&xFileFilterToGvariant, libs, "gtk_file_filter_to_gvariant")
326
327}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 102

↑↓ moveenter openesc close