v0.2.1 c0399be

gtklinkbutton.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// A button with a hyperlink.
16//
17// <picture>
18//
19//	<source srcset="link-button-dark.png" media="(prefers-color-scheme: dark)">
20//	<img alt="An example GtkLinkButton" src="link-button.png">
21//
22// </picture>
23//
24// It is useful to show quick links to resources.
25//
26// A link button is created by calling either [ctor@Gtk.LinkButton.new] or
27// [ctor@Gtk.LinkButton.new_with_label]. If using the former, the URI you
28// pass to the constructor is used as a label for the widget.
29//
30// The URI bound to a `GtkLinkButton` can be set specifically using
31// [method@Gtk.LinkButton.set_uri].
32//
33// By default, `GtkLinkButton` calls [method@Gtk.FileLauncher.launch] when the button
34// is clicked. This behaviour can be overridden by connecting to the
35// [signal@Gtk.LinkButton::activate-link] signal and returning %TRUE from
36// the signal handler.
37//
38// # Shortcuts and Gestures
39//
40// `GtkLinkButton` supports the following keyboard shortcuts:
41//
42// - <kbd>Shift</kbd>+<kbd>F10</kbd> or <kbd>Menu</kbd> opens the context menu.
43//
44// # Actions
45//
46// `GtkLinkButton` defines a set of built-in actions:
47//
48// - `clipboard.copy` copies the url to the clipboard.
49// - `menu.popup` opens the context menu.
50//
51// # CSS nodes
52//
53// `GtkLinkButton` has a single CSS node with name button. To differentiate
54// it from a plain `GtkButton`, it gets the .link style class.
55//
56// # Accessibility
57//
58// `GtkLinkButton` uses the [enum@Gtk.AccessibleRole.link] role.
59type LinkButton struct {
60	Button
61}
62
63var xLinkButtonGLibType func() types.GType
64
65func LinkButtonGLibType() types.GType {
66	return xLinkButtonGLibType()
67}
68
69func LinkButtonNewFromInternalPtr(ptr uintptr) *LinkButton {
70	cls := &LinkButton{}
71	cls.Ptr = ptr
72	return cls
73}
74
75var xNewLinkButton func(string) uintptr
76
77// Creates a new `GtkLinkButton` with the URI as its text.
78func NewLinkButton(UriVar string) *LinkButton {
79	var cls *LinkButton
80
81	cret := xNewLinkButton(UriVar)
82
83	if cret == 0 {
84		return nil
85	}
86	gobject.IncreaseRef(cret)
87	cls = &LinkButton{}
88	cls.Ptr = cret
89	return cls
90}
91
92var xNewLinkButtonWithLabel func(string, uintptr) uintptr
93
94// Creates a new `GtkLinkButton` containing a label.
95func NewLinkButtonWithLabel(UriVar string, LabelVar *string) *LinkButton {
96	var cls *LinkButton
97
98	LabelVarPtr := core.GStrdupNullable(LabelVar)
99	defer core.GFreeNullable(LabelVarPtr)
100
101	cret := xNewLinkButtonWithLabel(UriVar, LabelVarPtr)
102
103	if cret == 0 {
104		return nil
105	}
106	gobject.IncreaseRef(cret)
107	cls = &LinkButton{}
108	cls.Ptr = cret
109	return cls
110}
111
112var xLinkButtonGetUri func(uintptr) string
113
114// Retrieves the URI of the `GtkLinkButton`.
115func (x *LinkButton) GetUri() string {
116
117	cret := xLinkButtonGetUri(x.GoPointer())
118	return cret
119}
120
121var xLinkButtonGetVisited func(uintptr) bool
122
123// Retrieves the “visited” state of the `GtkLinkButton`.
124//
125// The button becomes visited when it is clicked. If the URI
126// is changed on the button, the “visited” state is unset again.
127//
128// The state may also be changed using [method@Gtk.LinkButton.set_visited].
129func (x *LinkButton) GetVisited() bool {
130
131	cret := xLinkButtonGetVisited(x.GoPointer())
132	return cret
133}
134
135var xLinkButtonSetUri func(uintptr, string)
136
137// Sets @uri as the URI where the `GtkLinkButton` points.
138//
139// As a side-effect this unsets the “visited” state of the button.
140func (x *LinkButton) SetUri(UriVar string) {
141
142	xLinkButtonSetUri(x.GoPointer(), UriVar)
143
144}
145
146var xLinkButtonSetVisited func(uintptr, bool)
147
148// Sets the “visited” state of the `GtkLinkButton`.
149//
150// See [method@Gtk.LinkButton.get_visited] for more details.
151func (x *LinkButton) SetVisited(VisitedVar bool) {
152
153	xLinkButtonSetVisited(x.GoPointer(), VisitedVar)
154
155}
156
157func (c *LinkButton) GoPointer() uintptr {
158	if c == nil {
159		return 0
160	}
161	return c.Ptr
162}
163
164func (c *LinkButton) SetGoPointer(ptr uintptr) {
165	c.Ptr = ptr
166}
167
168// SetPropertyUri sets the "uri" property.
169// The URI bound to this button.
170func (x *LinkButton) SetPropertyUri(value string) {
171	var v gobject.Value
172	v.Init(gobject.TypeStringVal)
173	v.SetString(&value)
174	x.SetProperty("uri", &v)
175}
176
177// GetPropertyUri gets the "uri" property.
178// The URI bound to this button.
179func (x *LinkButton) GetPropertyUri() string {
180	var v gobject.Value
181	x.GetProperty("uri", &v)
182	return v.GetString()
183}
184
185// SetPropertyVisited sets the "visited" property.
186// The 'visited' state of this button.
187//
188// A visited link is drawn in a different color.
189func (x *LinkButton) SetPropertyVisited(value bool) {
190	var v gobject.Value
191	v.Init(gobject.TypeBooleanVal)
192	v.SetBoolean(value)
193	x.SetProperty("visited", &v)
194}
195
196// GetPropertyVisited gets the "visited" property.
197// The 'visited' state of this button.
198//
199// A visited link is drawn in a different color.
200func (x *LinkButton) GetPropertyVisited() bool {
201	var v gobject.Value
202	x.GetProperty("visited", &v)
203	return v.GetBoolean()
204}
205
206// Emitted each time the `GtkLinkButton` is clicked.
207//
208// The default handler will call [method@Gtk.FileLauncher.launch] with the URI
209// stored inside the [property@Gtk.LinkButton:uri] property.
210//
211// To override the default behavior, you can connect to the
212// ::activate-link signal and stop the propagation of the signal
213// by returning %TRUE from your handler.
214func (x *LinkButton) ConnectActivateLink(cb *func(LinkButton) bool) uint {
215	cbPtr := uintptr(unsafe.Pointer(cb))
216	if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
217		handlerID := gobject.SignalConnect(x.GoPointer(), "activate-link", cbRefPtr)
218		glib.SaveHandlerMapping(handlerID, cbPtr)
219		return handlerID
220	}
221
222	fcb := func(clsPtr uintptr) bool {
223		fa := LinkButton{}
224		fa.Ptr = clsPtr
225		cbFn := *cb
226
227		return cbFn(fa)
228
229	}
230	cbRefPtr := purego.NewCallback(fcb)
231	glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
232	handlerID := gobject.SignalConnect(x.GoPointer(), "activate-link", cbRefPtr)
233	glib.SaveHandlerMapping(handlerID, cbPtr)
234	return handlerID
235}
236
237// Requests the user's screen reader to announce the given message.
238//
239// This kind of notification is useful for messages that
240// either have only a visual representation or that are not
241// exposed visually at all, e.g. a notification about a
242// successful operation.
243//
244// Also, by using this API, you can ensure that the message
245// does not interrupts the user's current screen reader output.
246func (x *LinkButton) Announce(MessageVar string, PriorityVar AccessibleAnnouncementPriority) {
247
248	XGtkAccessibleAnnounce(x.GoPointer(), MessageVar, PriorityVar)
249
250}
251
252// Retrieves the accessible parent for an accessible object.
253//
254// This function returns `NULL` for top level widgets.
255func (x *LinkButton) GetAccessibleParent() *AccessibleBase {
256	var cls *AccessibleBase
257
258	cret := XGtkAccessibleGetAccessibleParent(x.GoPointer())
259
260	if cret == 0 {
261		return nil
262	}
263	cls = &AccessibleBase{}
264	cls.Ptr = cret
265	return cls
266}
267
268// Retrieves the accessible role of an accessible object.
269func (x *LinkButton) GetAccessibleRole() AccessibleRole {
270
271	cret := XGtkAccessibleGetAccessibleRole(x.GoPointer())
272	return cret
273}
274
275// Retrieves the implementation for the given accessible object.
276func (x *LinkButton) GetAtContext() *ATContext {
277	var cls *ATContext
278
279	cret := XGtkAccessibleGetAtContext(x.GoPointer())
280
281	if cret == 0 {
282		return nil
283	}
284	cls = &ATContext{}
285	cls.Ptr = cret
286	return cls
287}
288
289// Queries the coordinates and dimensions of this accessible
290//
291// This functionality can be overridden by `GtkAccessible`
292// implementations, e.g. to get the bounds from an ignored
293// child widget.
294func (x *LinkButton) GetBounds(XVar *int, YVar *int, WidthVar *int, HeightVar *int) bool {
295
296	cret := XGtkAccessibleGetBounds(x.GoPointer(), XVar, YVar, WidthVar, HeightVar)
297	return cret
298}
299
300// Retrieves the first accessible child of an accessible object.
301func (x *LinkButton) GetFirstAccessibleChild() *AccessibleBase {
302	var cls *AccessibleBase
303
304	cret := XGtkAccessibleGetFirstAccessibleChild(x.GoPointer())
305
306	if cret == 0 {
307		return nil
308	}
309	cls = &AccessibleBase{}
310	cls.Ptr = cret
311	return cls
312}
313
314// Retrieves the next accessible sibling of an accessible object
315func (x *LinkButton) GetNextAccessibleSibling() *AccessibleBase {
316	var cls *AccessibleBase
317
318	cret := XGtkAccessibleGetNextAccessibleSibling(x.GoPointer())
319
320	if cret == 0 {
321		return nil
322	}
323	cls = &AccessibleBase{}
324	cls.Ptr = cret
325	return cls
326}
327
328// Queries a platform state, such as focus.
329//
330// This functionality can be overridden by `GtkAccessible`
331// implementations, e.g. to get platform state from an ignored
332// child widget, as is the case for `GtkText` wrappers.
333func (x *LinkButton) GetPlatformState(StateVar AccessiblePlatformState) bool {
334
335	cret := XGtkAccessibleGetPlatformState(x.GoPointer(), StateVar)
336	return cret
337}
338
339// Resets the accessible property to its default value.
340func (x *LinkButton) ResetProperty(PropertyVar AccessibleProperty) {
341
342	XGtkAccessibleResetProperty(x.GoPointer(), PropertyVar)
343
344}
345
346// Resets the accessible relation to its default value.
347func (x *LinkButton) ResetRelation(RelationVar AccessibleRelation) {
348
349	XGtkAccessibleResetRelation(x.GoPointer(), RelationVar)
350
351}
352
353// Resets the accessible state to its default value.
354func (x *LinkButton) ResetState(StateVar AccessibleState) {
355
356	XGtkAccessibleResetState(x.GoPointer(), StateVar)
357
358}
359
360// Sets the parent and sibling of an accessible object.
361//
362// This function is meant to be used by accessible implementations that are
363// not part of the widget hierarchy, and but act as a logical bridge between
364// widgets. For instance, if a widget creates an object that holds metadata
365// for each child, and you want that object to implement the `GtkAccessible`
366// interface, you will use this function to ensure that the parent of each
367// child widget is the metadata object, and the parent of each metadata
368// object is the container widget.
369func (x *LinkButton) SetAccessibleParent(ParentVar Accessible, NextSiblingVar Accessible) {
370
371	XGtkAccessibleSetAccessibleParent(x.GoPointer(), ParentVar.GoPointer(), NextSiblingVar.GoPointer())
372
373}
374
375// Updates the next accessible sibling.
376//
377// That might be useful when a new child of a custom accessible
378// is created, and it needs to be linked to a previous child.
379func (x *LinkButton) UpdateNextAccessibleSibling(NewSiblingVar Accessible) {
380
381	XGtkAccessibleUpdateNextAccessibleSibling(x.GoPointer(), NewSiblingVar.GoPointer())
382
383}
384
385// Informs ATs that the platform state has changed.
386//
387// This function should be used by `GtkAccessible` implementations that
388// have a platform state but are not widgets. Widgets handle platform
389// states automatically.
390func (x *LinkButton) UpdatePlatformState(StateVar AccessiblePlatformState) {
391
392	XGtkAccessibleUpdatePlatformState(x.GoPointer(), StateVar)
393
394}
395
396// Updates a list of accessible properties.
397//
398// See the [enum@Gtk.AccessibleProperty] documentation for the
399// value types of accessible properties.
400//
401// This function should be called by `GtkWidget` types whenever
402// an accessible property change must be communicated to assistive
403// technologies.
404//
405// Example:
406// ```c
407// value = gtk_adjustment_get_value (adjustment);
408// gtk_accessible_update_property (GTK_ACCESSIBLE (spin_button),
409//
410//	GTK_ACCESSIBLE_PROPERTY_VALUE_NOW, value,
411//	-1);
412//
413// ```
414func (x *LinkButton) UpdateProperty(FirstPropertyVar AccessibleProperty, varArgs ...interface{}) {
415
416	XGtkAccessibleUpdateProperty(x.GoPointer(), FirstPropertyVar, varArgs...)
417
418}
419
420// Updates an array of accessible properties.
421//
422// This function should be called by `GtkWidget` types whenever an accessible
423// property change must be communicated to assistive technologies.
424//
425// This function is meant to be used by language bindings.
426func (x *LinkButton) UpdatePropertyValue(NPropertiesVar int, PropertiesVar []AccessibleProperty, ValuesVar []gobject.Value) {
427
428	XGtkAccessibleUpdatePropertyValue(x.GoPointer(), NPropertiesVar, PropertiesVar, ValuesVar)
429
430}
431
432// Updates a list of accessible relations.
433//
434// This function should be called by `GtkWidget` types whenever an accessible
435// relation change must be communicated to assistive technologies.
436//
437// If the [enum@Gtk.AccessibleRelation] requires a list of references,
438// you should pass each reference individually, followed by `NULL`, e.g.
439//
440// ```c
441// gtk_accessible_update_relation (accessible,
442//
443//	GTK_ACCESSIBLE_RELATION_CONTROLS,
444//	  ref1, NULL,
445//	GTK_ACCESSIBLE_RELATION_LABELLED_BY,
446//	  ref1, ref2, ref3, NULL,
447//	-1);
448//
449// ```
450func (x *LinkButton) UpdateRelation(FirstRelationVar AccessibleRelation, varArgs ...interface{}) {
451
452	XGtkAccessibleUpdateRelation(x.GoPointer(), FirstRelationVar, varArgs...)
453
454}
455
456// Updates an array of accessible relations.
457//
458// This function should be called by `GtkWidget` types whenever an accessible
459// relation change must be communicated to assistive technologies.
460//
461// This function is meant to be used by language bindings.
462func (x *LinkButton) UpdateRelationValue(NRelationsVar int, RelationsVar []AccessibleRelation, ValuesVar []gobject.Value) {
463
464	XGtkAccessibleUpdateRelationValue(x.GoPointer(), NRelationsVar, RelationsVar, ValuesVar)
465
466}
467
468// Updates a list of accessible states.
469//
470// See the [enum@Gtk.AccessibleState] documentation for the
471// value types of accessible states.
472//
473// This function should be called by `GtkWidget` types whenever
474// an accessible state change must be communicated to assistive
475// technologies.
476//
477// Example:
478//
479// ```c
480// value = GTK_ACCESSIBLE_TRISTATE_MIXED;
481// gtk_accessible_update_state (GTK_ACCESSIBLE (check_button),
482//
483//	GTK_ACCESSIBLE_STATE_CHECKED, value,
484//	-1);
485//
486// ```
487func (x *LinkButton) UpdateState(FirstStateVar AccessibleState, varArgs ...interface{}) {
488
489	XGtkAccessibleUpdateState(x.GoPointer(), FirstStateVar, varArgs...)
490
491}
492
493// Updates an array of accessible states.
494//
495// This function should be called by `GtkWidget` types whenever an accessible
496// state change must be communicated to assistive technologies.
497//
498// This function is meant to be used by language bindings.
499func (x *LinkButton) UpdateStateValue(NStatesVar int, StatesVar []AccessibleState, ValuesVar []gobject.Value) {
500
501	XGtkAccessibleUpdateStateValue(x.GoPointer(), NStatesVar, StatesVar, ValuesVar)
502
503}
504
505// Gets the action name for @actionable.
506func (x *LinkButton) GetActionName() string {
507
508	cret := XGtkActionableGetActionName(x.GoPointer())
509	return cret
510}
511
512// Gets the current target value of @actionable.
513func (x *LinkButton) GetActionTargetValue() *glib.Variant {
514
515	cret := XGtkActionableGetActionTargetValue(x.GoPointer())
516	return cret
517}
518
519// Specifies the name of the action with which this widget should be
520// associated.
521//
522// If @action_name is %NULL then the widget will be unassociated from
523// any previous action.
524//
525// Usually this function is used when the widget is located (or will be
526// located) within the hierarchy of a `GtkApplicationWindow`.
527//
528// Names are of the form “win.save” or “app.quit” for actions on the
529// containing [class@ApplicationWindow] or its associated [class@Application],
530// respectively. This is the same form used for actions in the [class@Gio.Menu]
531// associated with the window.
532func (x *LinkButton) SetActionName(ActionNameVar *string) {
533
534	ActionNameVarPtr := core.GStrdupNullable(ActionNameVar)
535	defer core.GFreeNullable(ActionNameVarPtr)
536
537	XGtkActionableSetActionName(x.GoPointer(), ActionNameVarPtr)
538
539}
540
541// Sets the target of an actionable widget.
542//
543// This is a convenience function that calls [ctor@GLib.Variant.new] for
544// @format_string and uses the result to call
545// [method@Gtk.Actionable.set_action_target_value].
546//
547// If you are setting a string-valued target and want to set
548// the action name at the same time, you can use
549// [method@Gtk.Actionable.set_detailed_action_name].
550func (x *LinkButton) SetActionTarget(FormatStringVar string, varArgs ...interface{}) {
551
552	XGtkActionableSetActionTarget(x.GoPointer(), FormatStringVar, varArgs...)
553
554}
555
556// Sets the target value of an actionable widget.
557//
558// If @target_value is %NULL then the target value is unset.
559//
560// The target value has two purposes. First, it is used as the parameter
561// to activation of the action associated with the `GtkActionable` widget.
562// Second, it is used to determine if the widget should be rendered as
563// “active” — the widget is active if the state is equal to the given target.
564//
565// Consider the example of associating a set of buttons with a [iface@Gio.Action]
566// with string state in a typical “radio button” situation. Each button
567// will be associated with the same action, but with a different target
568// value for that action. Clicking on a particular button will activate
569// the action with the target of that button, which will typically cause
570// the action’s state to change to that value. Since the action’s state
571// is now equal to the target value of the button, the button will now
572// be rendered as active (and the other buttons, with different targets,
573// rendered inactive).
574func (x *LinkButton) SetActionTargetValue(TargetValueVar *glib.Variant) {
575
576	XGtkActionableSetActionTargetValue(x.GoPointer(), TargetValueVar)
577
578}
579
580// Sets the action-name and associated string target value of an
581// actionable widget.
582//
583// @detailed_action_name is a string in the format accepted by
584// [func@Gio.Action.parse_detailed_name].
585func (x *LinkButton) SetDetailedActionName(DetailedActionNameVar string) {
586
587	XGtkActionableSetDetailedActionName(x.GoPointer(), DetailedActionNameVar)
588
589}
590
591// Gets the ID of the @buildable object.
592//
593// `GtkBuilder` sets the name based on the ID attribute
594// of the `<object>` tag used to construct the @buildable.
595func (x *LinkButton) GetBuildableId() string {
596
597	cret := XGtkBuildableGetBuildableId(x.GoPointer())
598	return cret
599}
600
601func init() {
602	core.SetPackageName("GTK", "gtk4")
603	core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
604	var libs []uintptr
605	for _, libPath := range core.GetPaths("GTK") {
606		lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
607		if err != nil {
608			panic(err)
609		}
610		libs = append(libs, lib)
611	}
612
613	core.PuregoSafeRegister(&xLinkButtonGLibType, libs, "gtk_link_button_get_type")
614
615	core.PuregoSafeRegister(&xNewLinkButton, libs, "gtk_link_button_new")
616	core.PuregoSafeRegister(&xNewLinkButtonWithLabel, libs, "gtk_link_button_new_with_label")
617
618	core.PuregoSafeRegister(&xLinkButtonGetUri, libs, "gtk_link_button_get_uri")
619	core.PuregoSafeRegister(&xLinkButtonGetVisited, libs, "gtk_link_button_get_visited")
620	core.PuregoSafeRegister(&xLinkButtonSetUri, libs, "gtk_link_button_set_uri")
621	core.PuregoSafeRegister(&xLinkButtonSetVisited, libs, "gtk_link_button_set_visited")
622
623}

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