v0.2.1 c0399be

gtkstringlist.go RawHistoryFolder

1// Package gtk was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gtk
3
4import (
5	"structs"
6	"unsafe"
7
8	"github.com/ebitengine/purego"
9
10	"github.com/bnema/puregotk/pkg/core"
11	"github.com/bnema/puregotk/v4/gio"
12	"github.com/bnema/puregotk/v4/glib"
13	"github.com/bnema/puregotk/v4/gobject"
14	"github.com/bnema/puregotk/v4/gobject/types"
15)
16
17type StringListClass struct {
18	_ structs.HostLayout
19
20	ParentClass gobject.ObjectClass
21}
22
23func (x *StringListClass) GoPointer() uintptr {
24	return uintptr(unsafe.Pointer(x))
25}
26
27type StringObjectClass struct {
28	_ structs.HostLayout
29
30	ParentClass gobject.ObjectClass
31}
32
33func (x *StringObjectClass) GoPointer() uintptr {
34	return uintptr(unsafe.Pointer(x))
35}
36
37// A list model that wraps an array of strings.
38//
39// The objects in the model are of type [class@Gtk.StringObject] and have
40// a "string" property that can be used inside expressions.
41//
42// `GtkStringList` is well-suited for any place where you would
43// typically use a `char*[]`, but need a list model.
44//
45// ## GtkStringList as GtkBuildable
46//
47// The `GtkStringList` implementation of the `GtkBuildable` interface
48// supports adding items directly using the `<items>` element and
49// specifying `<item>` elements for each item. Each `<item>` element
50// supports the regular translation attributes “translatable”,
51// “context” and “comments”.
52//
53// Here is a UI definition fragment specifying a `GtkStringList`
54//
55// ```xml
56// <object class="GtkStringList">
57//
58//	<items>
59//	  <item translatable="yes">Factory</item>
60//	  <item translatable="yes">Home</item>
61//	  <item translatable="yes">Subway</item>
62//	</items>
63//
64// </object>
65// ```
66type StringList struct {
67	gobject.Object
68}
69
70var xStringListGLibType func() types.GType
71
72func StringListGLibType() types.GType {
73	return xStringListGLibType()
74}
75
76func StringListNewFromInternalPtr(ptr uintptr) *StringList {
77	cls := &StringList{}
78	cls.Ptr = ptr
79	return cls
80}
81
82var xNewStringList func([]string) uintptr
83
84// Creates a new `GtkStringList` with the given @strings.
85func NewStringList(StringsVar []string) *StringList {
86	var cls *StringList
87
88	cret := xNewStringList(StringsVar)
89
90	if cret == 0 {
91		return nil
92	}
93	cls = &StringList{}
94	cls.Ptr = cret
95	return cls
96}
97
98var xStringListAppend func(uintptr, string)
99
100// Appends @string to @self.
101//
102// The @string will be copied. See
103// [method@Gtk.StringList.take] for a way to avoid that.
104func (x *StringList) Append(StringVar string) {
105
106	xStringListAppend(x.GoPointer(), StringVar)
107
108}
109
110var xStringListFind func(uintptr, string) uint
111
112// Gets the position of the @string in @self.
113//
114// If @self does not contain @string item, `G_MAXUINT` is returned.
115func (x *StringList) Find(StringVar string) uint {
116
117	cret := xStringListFind(x.GoPointer(), StringVar)
118	return cret
119}
120
121var xStringListGetString func(uintptr, uint) string
122
123// Gets the string that is at @position in @self.
124//
125// If @self does not contain @position items, %NULL is returned.
126//
127// This function returns the const char *. To get the
128// object wrapping it, use g_list_model_get_item().
129func (x *StringList) GetString(PositionVar uint) string {
130
131	cret := xStringListGetString(x.GoPointer(), PositionVar)
132	return cret
133}
134
135var xStringListRemove func(uintptr, uint)
136
137// Removes the string at @position from @self.
138//
139// @position must be smaller than the current
140// length of the list.
141func (x *StringList) Remove(PositionVar uint) {
142
143	xStringListRemove(x.GoPointer(), PositionVar)
144
145}
146
147var xStringListSplice func(uintptr, uint, uint, []string)
148
149// Changes @self by removing @n_removals strings and adding @additions
150// to it.
151//
152// This function is more efficient than [method@Gtk.StringList.append]
153// and [method@Gtk.StringList.remove], because it only emits the
154// ::items-changed signal once for the change.
155//
156// This function copies the strings in @additions.
157//
158// The parameters @position and @n_removals must be correct (ie:
159// @position + @n_removals must be less than or equal to the length
160// of the list at the time this function is called).
161func (x *StringList) Splice(PositionVar uint, NRemovalsVar uint, AdditionsVar []string) {
162
163	xStringListSplice(x.GoPointer(), PositionVar, NRemovalsVar, AdditionsVar)
164
165}
166
167var xStringListTake func(uintptr, uintptr)
168
169// Adds @string to self at the end, and takes
170// ownership of it.
171//
172// This variant of [method@Gtk.StringList.append]
173// is convenient for formatting strings:
174//
175// ```c
176// gtk_string_list_take (self, g_strdup_print ("%d dollars", lots));
177// ```
178func (x *StringList) Take(StringVar string) {
179
180	xStringListTake(x.GoPointer(), core.GStrdup(StringVar))
181
182}
183
184func (c *StringList) GoPointer() uintptr {
185	if c == nil {
186		return 0
187	}
188	return c.Ptr
189}
190
191func (c *StringList) SetGoPointer(ptr uintptr) {
192	c.Ptr = ptr
193}
194
195// GetPropertyNItems gets the "n-items" property.
196// The number of items. See [method@Gio.ListModel.get_n_items].
197func (x *StringList) GetPropertyNItems() uint {
198	var v gobject.Value
199	x.GetProperty("n-items", &v)
200	return v.GetUint()
201}
202
203// SetPropertyStrings sets the "strings" property.
204// The strings in the model.
205func (x *StringList) SetPropertyStrings(value []string) {
206	var v gobject.Value
207	v.Init(glib.StrvGetType())
208	v.SetBoxed(uintptr(unsafe.Pointer(core.ByteSlice(value))))
209	x.SetProperty("strings", &v)
210}
211
212// Get the item at @position.
213//
214// If @position is greater than the number of items in @list, %NULL is
215// returned.
216//
217// %NULL is never returned for an index that is smaller than the length
218// of the list.
219//
220// See also: g_list_model_get_n_items()
221func (x *StringList) GetItem(PositionVar uint) uintptr {
222
223	cret := gio.XGListModelGetItem(x.GoPointer(), PositionVar)
224	return cret
225}
226
227// Gets the type of the items in @list.
228//
229// All items returned from g_list_model_get_item() are of the type
230// returned by this function, or a subtype, or if the type is an
231// interface, they are an implementation of that interface.
232//
233// The item type of a #GListModel can not change during the life of the
234// model.
235func (x *StringList) GetItemType() types.GType {
236
237	cret := gio.XGListModelGetItemType(x.GoPointer())
238	return cret
239}
240
241// Gets the number of items in @list.
242//
243// Depending on the model implementation, calling this function may be
244// less efficient than iterating the list with increasing values for
245// @position until g_list_model_get_item() returns %NULL.
246func (x *StringList) GetNItems() uint {
247
248	cret := gio.XGListModelGetNItems(x.GoPointer())
249	return cret
250}
251
252// Get the item at @position.
253//
254// If @position is greater than the number of items in @list, %NULL is
255// returned.
256//
257// %NULL is never returned for an index that is smaller than the length
258// of the list.
259//
260// This function is meant to be used by language bindings in place
261// of g_list_model_get_item().
262//
263// See also: g_list_model_get_n_items()
264func (x *StringList) GetObject(PositionVar uint) *gobject.Object {
265	var cls *gobject.Object
266
267	cret := gio.XGListModelGetObject(x.GoPointer(), PositionVar)
268
269	if cret == 0 {
270		return nil
271	}
272	cls = &gobject.Object{}
273	cls.Ptr = cret
274	return cls
275}
276
277// Emits the #GListModel::items-changed signal on @list.
278//
279// This function should only be called by classes implementing
280// #GListModel. It has to be called after the internal representation
281// of @list has been updated, because handlers connected to this signal
282// might query the new state of the list.
283//
284// Implementations must only make changes to the model (as visible to
285// its consumer) in places that will not cause problems for that
286// consumer.  For models that are driven directly by a write API (such
287// as #GListStore), changes can be reported in response to uses of that
288// API.  For models that represent remote data, changes should only be
289// made from a fresh mainloop dispatch.  It is particularly not
290// permitted to make changes in response to a call to the #GListModel
291// consumer API.
292//
293// Stated another way: in general, it is assumed that code making a
294// series of accesses to the model via the API, without returning to the
295// mainloop, and without calling other code, will continue to view the
296// same contents of the model.
297func (x *StringList) ItemsChanged(PositionVar uint, RemovedVar uint, AddedVar uint) {
298
299	gio.XGListModelItemsChanged(x.GoPointer(), PositionVar, RemovedVar, AddedVar)
300
301}
302
303// Gets the ID of the @buildable object.
304//
305// `GtkBuilder` sets the name based on the ID attribute
306// of the `<object>` tag used to construct the @buildable.
307func (x *StringList) GetBuildableId() string {
308
309	cret := XGtkBuildableGetBuildableId(x.GoPointer())
310	return cret
311}
312
313// The type of items in a `GtkStringList`.
314//
315// A `GtkStringObject` is a wrapper around a `const char*`; it has
316// a [property@Gtk.StringObject:string] property that can be used
317// for property bindings and expressions.
318type StringObject struct {
319	gobject.Object
320}
321
322var xStringObjectGLibType func() types.GType
323
324func StringObjectGLibType() types.GType {
325	return xStringObjectGLibType()
326}
327
328func StringObjectNewFromInternalPtr(ptr uintptr) *StringObject {
329	cls := &StringObject{}
330	cls.Ptr = ptr
331	return cls
332}
333
334var xNewStringObject func(string) uintptr
335
336// Wraps a string in an object for use with `GListModel`.
337func NewStringObject(StringVar string) *StringObject {
338	var cls *StringObject
339
340	cret := xNewStringObject(StringVar)
341
342	if cret == 0 {
343		return nil
344	}
345	cls = &StringObject{}
346	cls.Ptr = cret
347	return cls
348}
349
350var xStringObjectGetString func(uintptr) string
351
352// Returns the string contained in a `GtkStringObject`.
353func (x *StringObject) GetString() string {
354
355	cret := xStringObjectGetString(x.GoPointer())
356	return cret
357}
358
359func (c *StringObject) GoPointer() uintptr {
360	if c == nil {
361		return 0
362	}
363	return c.Ptr
364}
365
366func (c *StringObject) SetGoPointer(ptr uintptr) {
367	c.Ptr = ptr
368}
369
370// GetPropertyString gets the "string" property.
371// The string.
372func (x *StringObject) GetPropertyString() string {
373	var v gobject.Value
374	x.GetProperty("string", &v)
375	return v.GetString()
376}
377
378func init() {
379	core.SetPackageName("GTK", "gtk4")
380	core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
381	var libs []uintptr
382	for _, libPath := range core.GetPaths("GTK") {
383		lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
384		if err != nil {
385			panic(err)
386		}
387		libs = append(libs, lib)
388	}
389
390	core.PuregoSafeRegister(&xStringListGLibType, libs, "gtk_string_list_get_type")
391
392	core.PuregoSafeRegister(&xNewStringList, libs, "gtk_string_list_new")
393
394	core.PuregoSafeRegister(&xStringListAppend, libs, "gtk_string_list_append")
395	core.PuregoSafeRegister(&xStringListFind, libs, "gtk_string_list_find")
396	core.PuregoSafeRegister(&xStringListGetString, libs, "gtk_string_list_get_string")
397	core.PuregoSafeRegister(&xStringListRemove, libs, "gtk_string_list_remove")
398	core.PuregoSafeRegister(&xStringListSplice, libs, "gtk_string_list_splice")
399	core.PuregoSafeRegister(&xStringListTake, libs, "gtk_string_list_take")
400
401	core.PuregoSafeRegister(&xStringObjectGLibType, libs, "gtk_string_object_get_type")
402
403	core.PuregoSafeRegister(&xNewStringObject, libs, "gtk_string_object_new")
404
405	core.PuregoSafeRegister(&xStringObjectGetString, libs, "gtk_string_object_get_string")
406
407}

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