v0.2.1 c0399be

gsimpleaction.go RawHistoryFolder

1// Package gio was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gio
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 `GSimpleAction` is the obvious simple implementation of the
16// [iface@Gio.Action] interface. This is the easiest way to create an action for
17// purposes of adding it to a [class@Gio.SimpleActionGroup].
18type SimpleAction struct {
19	gobject.Object
20}
21
22var xSimpleActionGLibType func() types.GType
23
24func SimpleActionGLibType() types.GType {
25	return xSimpleActionGLibType()
26}
27
28func SimpleActionNewFromInternalPtr(ptr uintptr) *SimpleAction {
29	cls := &SimpleAction{}
30	cls.Ptr = ptr
31	return cls
32}
33
34var xNewSimpleAction func(string, *glib.VariantType) uintptr
35
36// Creates a new action.
37//
38// The created action is stateless. See g_simple_action_new_stateful() to create
39// an action that has state.
40func NewSimpleAction(NameVar string, ParameterTypeVar *glib.VariantType) *SimpleAction {
41	var cls *SimpleAction
42
43	cret := xNewSimpleAction(NameVar, ParameterTypeVar)
44
45	if cret == 0 {
46		return nil
47	}
48	cls = &SimpleAction{}
49	cls.Ptr = cret
50	return cls
51}
52
53var xNewSimpleActionStateful func(string, *glib.VariantType, *glib.Variant) uintptr
54
55// Creates a new stateful action.
56//
57// All future state values must have the same #GVariantType as the initial
58// @state.
59//
60// If the @state #GVariant is floating, it is consumed.
61func NewSimpleActionStateful(NameVar string, ParameterTypeVar *glib.VariantType, StateVar *glib.Variant) *SimpleAction {
62	var cls *SimpleAction
63
64	cret := xNewSimpleActionStateful(NameVar, ParameterTypeVar, StateVar)
65
66	if cret == 0 {
67		return nil
68	}
69	cls = &SimpleAction{}
70	cls.Ptr = cret
71	return cls
72}
73
74var xSimpleActionSetEnabled func(uintptr, bool)
75
76// Sets the action as enabled or not.
77//
78// An action must be enabled in order to be activated or in order to
79// have its state changed from outside callers.
80//
81// This should only be called by the implementor of the action.  Users
82// of the action should not attempt to modify its enabled flag.
83func (x *SimpleAction) SetEnabled(EnabledVar bool) {
84
85	xSimpleActionSetEnabled(x.GoPointer(), EnabledVar)
86
87}
88
89var xSimpleActionSetState func(uintptr, *glib.Variant)
90
91// Sets the state of the action.
92//
93// This directly updates the 'state' property to the given value.
94//
95// This should only be called by the implementor of the action.  Users
96// of the action should not attempt to directly modify the 'state'
97// property.  Instead, they should call g_action_change_state() to
98// request the change.
99//
100// If the @value GVariant is floating, it is consumed.
101func (x *SimpleAction) SetState(ValueVar *glib.Variant) {
102
103	xSimpleActionSetState(x.GoPointer(), ValueVar)
104
105}
106
107var xSimpleActionSetStateHint func(uintptr, *glib.Variant)
108
109// Sets the state hint for the action.
110//
111// See g_action_get_state_hint() for more information about
112// action state hints.
113func (x *SimpleAction) SetStateHint(StateHintVar *glib.Variant) {
114
115	xSimpleActionSetStateHint(x.GoPointer(), StateHintVar)
116
117}
118
119func (c *SimpleAction) GoPointer() uintptr {
120	if c == nil {
121		return 0
122	}
123	return c.Ptr
124}
125
126func (c *SimpleAction) SetGoPointer(ptr uintptr) {
127	c.Ptr = ptr
128}
129
130// SetPropertyEnabled sets the "enabled" property.
131// If @action is currently enabled.
132//
133// If the action is disabled then calls to g_action_activate() and
134// g_action_change_state() have no effect.
135func (x *SimpleAction) SetPropertyEnabled(value bool) {
136	var v gobject.Value
137	v.Init(gobject.TypeBooleanVal)
138	v.SetBoolean(value)
139	x.SetProperty("enabled", &v)
140}
141
142// GetPropertyEnabled gets the "enabled" property.
143// If @action is currently enabled.
144//
145// If the action is disabled then calls to g_action_activate() and
146// g_action_change_state() have no effect.
147func (x *SimpleAction) GetPropertyEnabled() bool {
148	var v gobject.Value
149	x.GetProperty("enabled", &v)
150	return v.GetBoolean()
151}
152
153// SetPropertyName sets the "name" property.
154// The name of the action. This is mostly meaningful for identifying
155// the action once it has been added to a #GSimpleActionGroup.
156func (x *SimpleAction) SetPropertyName(value string) {
157	var v gobject.Value
158	v.Init(gobject.TypeStringVal)
159	v.SetString(&value)
160	x.SetProperty("name", &v)
161}
162
163// GetPropertyName gets the "name" property.
164// The name of the action. This is mostly meaningful for identifying
165// the action once it has been added to a #GSimpleActionGroup.
166func (x *SimpleAction) GetPropertyName() string {
167	var v gobject.Value
168	x.GetProperty("name", &v)
169	return v.GetString()
170}
171
172// SetPropertyParameterType sets the "parameter-type" property.
173// The type of the parameter that must be given when activating the
174// action.
175func (x *SimpleAction) SetPropertyParameterType(value uintptr) {
176	var v gobject.Value
177	v.Init(gobject.TypePointerVal)
178	v.SetPointer(value)
179	x.SetProperty("parameter-type", &v)
180}
181
182// GetPropertyParameterType gets the "parameter-type" property.
183// The type of the parameter that must be given when activating the
184// action.
185func (x *SimpleAction) GetPropertyParameterType() uintptr {
186	var v gobject.Value
187	x.GetProperty("parameter-type", &v)
188	return v.GetPointer()
189}
190
191// SetPropertyState sets the "state" property.
192// The state of the action, or %NULL if the action is stateless.
193func (x *SimpleAction) SetPropertyState(value uintptr) {
194	var v gobject.Value
195	v.Init(gobject.TypePointerVal)
196	v.SetPointer(value)
197	x.SetProperty("state", &v)
198}
199
200// GetPropertyState gets the "state" property.
201// The state of the action, or %NULL if the action is stateless.
202func (x *SimpleAction) GetPropertyState() uintptr {
203	var v gobject.Value
204	x.GetProperty("state", &v)
205	return v.GetPointer()
206}
207
208// GetPropertyStateType gets the "state-type" property.
209// The #GVariantType of the state that the action has, or %NULL if the
210// action is stateless.
211func (x *SimpleAction) GetPropertyStateType() uintptr {
212	var v gobject.Value
213	x.GetProperty("state-type", &v)
214	return v.GetPointer()
215}
216
217// Indicates that the action was just activated.
218//
219// @parameter will always be of the expected type, i.e. the parameter type
220// specified when the action was created. If an incorrect type is given when
221// activating the action, this signal is not emitted.
222//
223// Since GLib 2.40, if no handler is connected to this signal then the
224// default behaviour for boolean-stated actions with a %NULL parameter
225// type is to toggle them via the #GSimpleAction::change-state signal.
226// For stateful actions where the state type is equal to the parameter
227// type, the default is to forward them directly to
228// #GSimpleAction::change-state.  This should allow almost all users
229// of #GSimpleAction to connect only one handler or the other.
230func (x *SimpleAction) ConnectActivate(cb *func(SimpleAction, uintptr)) uint {
231	cbPtr := uintptr(unsafe.Pointer(cb))
232	if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
233		handlerID := gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr)
234		glib.SaveHandlerMapping(handlerID, cbPtr)
235		return handlerID
236	}
237
238	fcb := func(clsPtr uintptr, ParameterVarp uintptr) {
239		fa := SimpleAction{}
240		fa.Ptr = clsPtr
241		cbFn := *cb
242
243		cbFn(fa, ParameterVarp)
244
245	}
246	cbRefPtr := purego.NewCallback(fcb)
247	glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
248	handlerID := gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr)
249	glib.SaveHandlerMapping(handlerID, cbPtr)
250	return handlerID
251}
252
253// Indicates that the action just received a request to change its
254// state.
255//
256// @value will always be of the correct state type, i.e. the type of the
257// initial state passed to g_simple_action_new_stateful(). If an incorrect
258// type is given when requesting to change the state, this signal is not
259// emitted.
260//
261// If no handler is connected to this signal then the default
262// behaviour is to call g_simple_action_set_state() to set the state
263// to the requested value. If you connect a signal handler then no
264// default action is taken. If the state should change then you must
265// call g_simple_action_set_state() from the handler.
266//
267// An example of a 'change-state' handler:
268// |[<!-- language="C" -->
269// static void
270// change_volume_state (GSimpleAction *action,
271//
272//	GVariant      *value,
273//	gpointer       user_data)
274//
275//	{
276//	  gint requested;
277//
278//	  requested = g_variant_get_int32 (value);
279//
280//	  // Volume only goes from 0 to 10
281//	  if (0 <= requested && requested <= 10)
282//	    g_simple_action_set_state (action, value);
283//	}
284//
285// ]|
286//
287// The handler need not set the state to the requested value.
288// It could set it to any value at all, or take some other action.
289func (x *SimpleAction) ConnectChangeState(cb *func(SimpleAction, uintptr)) uint {
290	cbPtr := uintptr(unsafe.Pointer(cb))
291	if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
292		handlerID := gobject.SignalConnect(x.GoPointer(), "change-state", cbRefPtr)
293		glib.SaveHandlerMapping(handlerID, cbPtr)
294		return handlerID
295	}
296
297	fcb := func(clsPtr uintptr, ValueVarp uintptr) {
298		fa := SimpleAction{}
299		fa.Ptr = clsPtr
300		cbFn := *cb
301
302		cbFn(fa, ValueVarp)
303
304	}
305	cbRefPtr := purego.NewCallback(fcb)
306	glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
307	handlerID := gobject.SignalConnect(x.GoPointer(), "change-state", cbRefPtr)
308	glib.SaveHandlerMapping(handlerID, cbPtr)
309	return handlerID
310}
311
312// Activates the action.
313//
314// @parameter must be the correct type of parameter for the action (ie:
315// the parameter type given at construction time).  If the parameter
316// type was `NULL` then @parameter must also be `NULL`.
317//
318// If the @parameter [type@GLib.Variant] is floating, it is consumed.
319func (x *SimpleAction) Activate(ParameterVar *glib.Variant) {
320
321	XGActionActivate(x.GoPointer(), ParameterVar)
322
323}
324
325// Request for the state of @action to be changed to @value.
326//
327// The action must be stateful and @value must be of the correct type.
328// See [method@Gio.Action.get_state_type].
329//
330// This call merely requests a change.  The action may refuse to change
331// its state or may change its state to something other than @value.
332// See [method@Gio.Action.get_state_hint].
333//
334// If the @value [type@GLib.Variant] is floating, it is consumed.
335func (x *SimpleAction) ChangeState(ValueVar *glib.Variant) {
336
337	XGActionChangeState(x.GoPointer(), ValueVar)
338
339}
340
341// Checks if @action is currently enabled.
342//
343// An action must be enabled in order to be activated or in order to
344// have its state changed from outside callers.
345func (x *SimpleAction) GetEnabled() bool {
346
347	cret := XGActionGetEnabled(x.GoPointer())
348	return cret
349}
350
351// Queries the name of @action.
352func (x *SimpleAction) GetName() string {
353
354	cret := XGActionGetName(x.GoPointer())
355	return cret
356}
357
358// Queries the type of the parameter that must be given when activating
359// @action.
360//
361// When activating the action using [method@Gio.Action.activate], the
362// [type@GLib.Variant] given to that function must be of the type returned by
363// this function.
364//
365// In the case that this function returns `NULL`, you must not give any
366// [type@GLib.Variant], but `NULL` instead.
367func (x *SimpleAction) GetParameterType() *glib.VariantType {
368
369	cret := XGActionGetParameterType(x.GoPointer())
370	return cret
371}
372
373// Queries the current state of @action.
374//
375// If the action is not stateful then `NULL` will be returned.  If the
376// action is stateful then the type of the return value is the type
377// given by [method@Gio.Action.get_state_type].
378//
379// The return value (if non-`NULL`) should be freed with
380// [method@GLib.Variant.unref] when it is no longer required.
381func (x *SimpleAction) GetState() *glib.Variant {
382
383	cret := XGActionGetState(x.GoPointer())
384	return cret
385}
386
387// Requests a hint about the valid range of values for the state of
388// @action.
389//
390// If `NULL` is returned it either means that the action is not stateful
391// or that there is no hint about the valid range of values for the
392// state of the action.
393//
394// If a [type@GLib.Variant] array is returned then each item in the array is a
395// possible value for the state.  If a [type@GLib.Variant] pair (ie: two-tuple) is
396// returned then the tuple specifies the inclusive lower and upper bound
397// of valid values for the state.
398//
399// In any case, the information is merely a hint.  It may be possible to
400// have a state value outside of the hinted range and setting a value
401// within the range may fail.
402//
403// The return value (if non-`NULL`) should be freed with
404// [method@GLib.Variant.unref] when it is no longer required.
405func (x *SimpleAction) GetStateHint() *glib.Variant {
406
407	cret := XGActionGetStateHint(x.GoPointer())
408	return cret
409}
410
411// Queries the type of the state of @action.
412//
413// If the action is stateful (e.g. created with
414// [ctor@Gio.SimpleAction.new_stateful]) then this function returns the
415// [type@GLib.VariantType] of the state.  This is the type of the initial value
416// given as the state. All calls to [method@Gio.Action.change_state] must give a
417// [type@GLib.Variant] of this type and [method@Gio.Action.get_state] will return a
418// [type@GLib.Variant] of the same type.
419//
420// If the action is not stateful (e.g. created with [ctor@Gio.SimpleAction.new])
421// then this function will return `NULL`. In that case, [method@Gio.Action.get_state]
422// will return `NULL` and you must not call [method@Gio.Action.change_state].
423func (x *SimpleAction) GetStateType() *glib.VariantType {
424
425	cret := XGActionGetStateType(x.GoPointer())
426	return cret
427}
428
429func init() {
430	core.SetPackageName("GIO", "gio-2.0")
431	core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"})
432	var libs []uintptr
433	for _, libPath := range core.GetPaths("GIO") {
434		lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
435		if err != nil {
436			panic(err)
437		}
438		libs = append(libs, lib)
439	}
440
441	core.PuregoSafeRegister(&xSimpleActionGLibType, libs, "g_simple_action_get_type")
442
443	core.PuregoSafeRegister(&xNewSimpleAction, libs, "g_simple_action_new")
444	core.PuregoSafeRegister(&xNewSimpleActionStateful, libs, "g_simple_action_new_stateful")
445
446	core.PuregoSafeRegister(&xSimpleActionSetEnabled, libs, "g_simple_action_set_enabled")
447	core.PuregoSafeRegister(&xSimpleActionSetState, libs, "g_simple_action_set_state")
448	core.PuregoSafeRegister(&xSimpleActionSetStateHint, libs, "g_simple_action_set_state_hint")
449
450}

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