返回 DeepSeek-Reasonix
dbus_menu.go
1 // Code generated by dbus-codegen-go DO NOT EDIT.
2 package menu
3
4 import (
5 "context"
6 "errors"
7 "fmt"
8 "github.com/godbus/dbus/v5"
9 "github.com/godbus/dbus/v5/introspect"
10 )
11
12 var (
13 // Introspection for com.canonical.dbusmenu
14 IntrospectDataDbusmenu = introspect.Interface{
15 Name: "com.canonical.dbusmenu",
16 Methods: []introspect.Method{{Name: "GetLayout", Args: []introspect.Arg{
17 {Name: "parentId", Type: "i", Direction: "in"},
18 {Name: "recursionDepth", Type: "i", Direction: "in"},
19 {Name: "propertyNames", Type: "as", Direction: "in"},
20 {Name: "revision", Type: "u", Direction: "out"},
21 {Name: "layout", Type: "(ia{sv}av)", Direction: "out"},
22 }},
23 {Name: "GetGroupProperties", Args: []introspect.Arg{
24 {Name: "ids", Type: "ai", Direction: "in"},
25 {Name: "propertyNames", Type: "as", Direction: "in"},
26 {Name: "properties", Type: "a(ia{sv})", Direction: "out"},
27 }},
28 {Name: "GetProperty", Args: []introspect.Arg{
29 {Name: "id", Type: "i", Direction: "in"},
30 {Name: "name", Type: "s", Direction: "in"},
31 {Name: "value", Type: "v", Direction: "out"},
32 }},
33 {Name: "Event", Args: []introspect.Arg{
34 {Name: "id", Type: "i", Direction: "in"},
35 {Name: "eventId", Type: "s", Direction: "in"},
36 {Name: "data", Type: "v", Direction: "in"},
37 {Name: "timestamp", Type: "u", Direction: "in"},
38 }},
39 {Name: "EventGroup", Args: []introspect.Arg{
40 {Name: "events", Type: "a(isvu)", Direction: "in"},
41 {Name: "idErrors", Type: "ai", Direction: "out"},
42 }},
43 {Name: "AboutToShow", Args: []introspect.Arg{
44 {Name: "id", Type: "i", Direction: "in"},
45 {Name: "needUpdate", Type: "b", Direction: "out"},
46 }},
47 {Name: "AboutToShowGroup", Args: []introspect.Arg{
48 {Name: "ids", Type: "ai", Direction: "in"},
49 {Name: "updatesNeeded", Type: "ai", Direction: "out"},
50 {Name: "idErrors", Type: "ai", Direction: "out"},
51 }},
52 },
53 Signals: []introspect.Signal{{Name: "ItemsPropertiesUpdated", Args: []introspect.Arg{
54 {Name: "updatedProps", Type: "a(ia{sv})", Direction: "out"},
55 {Name: "removedProps", Type: "a(ias)", Direction: "out"},
56 }},
57 {Name: "LayoutUpdated", Args: []introspect.Arg{
58 {Name: "revision", Type: "u", Direction: "out"},
59 {Name: "parent", Type: "i", Direction: "out"},
60 }},
61 {Name: "ItemActivationRequested", Args: []introspect.Arg{
62 {Name: "id", Type: "i", Direction: "out"},
63 {Name: "timestamp", Type: "u", Direction: "out"},
64 }},
65 },
66 Properties: []introspect.Property{{Name: "Version", Type: "u", Access: "read"},
67 {Name: "TextDirection", Type: "s", Access: "read"},
68 {Name: "Status", Type: "s", Access: "read"},
69 {Name: "IconThemePath", Type: "as", Access: "read"},
70 },
71 Annotations: []introspect.Annotation{},
72 }
73 )
74
75 // Signal is a common interface for all signals.
76 type Signal interface {
77 Name() string
78 Interface() string
79 Sender() string
80
81 path() dbus.ObjectPath
82 values() []interface{}
83 }
84
85 // Emit sends the given signal to the bus.
86 func Emit(conn *dbus.Conn, s Signal) error {
87 return conn.Emit(s.path(), s.Interface()+"."+s.Name(), s.values()...)
88 }
89
90 // ErrUnknownSignal is returned by LookupSignal when a signal cannot be resolved.
91 var ErrUnknownSignal = errors.New("unknown signal")
92
93 // LookupSignal converts the given raw D-Bus signal with variable body
94 // into one with typed structured body or returns ErrUnknownSignal error.
95 func LookupSignal(signal *dbus.Signal) (Signal, error) {
96 switch signal.Name {
97 case InterfaceDbusmenu + "." + "ItemsPropertiesUpdated":
98 if len(signal.Body) < 2 {
99 return nil, fmt.Errorf("signal has %v args rather than the expected 2", len(signal.Body))
100 }
101 v0, ok := signal.Body[0].([]struct {
102 V0 int32
103 V1 map[string]dbus.Variant
104 })
105 if !ok {
106 return nil, fmt.Errorf("prop .UpdatedProps is %T, not []struct {V0 int32;V1 map[string]dbus.Variant}", signal.Body[0])
107 }
108 v1, ok := signal.Body[1].([]struct {
109 V0 int32
110 V1 []string
111 })
112 if !ok {
113 return nil, fmt.Errorf("prop .RemovedProps is %T, not []struct {V0 int32;V1 []string}", signal.Body[1])
114 }
115 return &Dbusmenu_ItemsPropertiesUpdatedSignal{
116 sender: signal.Sender,
117 Path: signal.Path,
118 Body: &Dbusmenu_ItemsPropertiesUpdatedSignalBody{
119 UpdatedProps: v0,
120 RemovedProps: v1,
121 },
122 }, nil
123 case InterfaceDbusmenu + "." + "LayoutUpdated":
124 if len(signal.Body) < 2 {
125 return nil, fmt.Errorf("signal has %v args rather than the expected 2", len(signal.Body))
126 }
127 v0, ok := signal.Body[0].(uint32)
128 if !ok {
129 return nil, fmt.Errorf("prop .Revision is %T, not uint32", signal.Body[0])
130 }
131 v1, ok := signal.Body[1].(int32)
132 if !ok {
133 return nil, fmt.Errorf("prop .Parent is %T, not int32", signal.Body[1])
134 }
135 return &Dbusmenu_LayoutUpdatedSignal{
136 sender: signal.Sender,
137 Path: signal.Path,
138 Body: &Dbusmenu_LayoutUpdatedSignalBody{
139 Revision: v0,
140 Parent: v1,
141 },
142 }, nil
143 case InterfaceDbusmenu + "." + "ItemActivationRequested":
144 if len(signal.Body) < 2 {
145 return nil, fmt.Errorf("signal has %v args rather than the expected 2", len(signal.Body))
146 }
147 v0, ok := signal.Body[0].(int32)
148 if !ok {
149 return nil, fmt.Errorf("prop .Id is %T, not int32", signal.Body[0])
150 }
151 v1, ok := signal.Body[1].(uint32)
152 if !ok {
153 return nil, fmt.Errorf("prop .Timestamp is %T, not uint32", signal.Body[1])
154 }
155 return &Dbusmenu_ItemActivationRequestedSignal{
156 sender: signal.Sender,
157 Path: signal.Path,
158 Body: &Dbusmenu_ItemActivationRequestedSignalBody{
159 Id: v0,
160 Timestamp: v1,
161 },
162 }, nil
163 default:
164 return nil, ErrUnknownSignal
165 }
166 }
167
168 // AddMatchSignal registers a match rule for the given signal,
169 // opts are appended to the automatically generated signal's rules.
170 func AddMatchSignal(conn *dbus.Conn, s Signal, opts ...dbus.MatchOption) error {
171 return conn.AddMatchSignal(append([]dbus.MatchOption{
172 dbus.WithMatchInterface(s.Interface()),
173 dbus.WithMatchMember(s.Name()),
174 }, opts...)...)
175 }
176
177 // RemoveMatchSignal unregisters the previously registered subscription.
178 func RemoveMatchSignal(conn *dbus.Conn, s Signal, opts ...dbus.MatchOption) error {
179 return conn.RemoveMatchSignal(append([]dbus.MatchOption{
180 dbus.WithMatchInterface(s.Interface()),
181 dbus.WithMatchMember(s.Name()),
182 }, opts...)...)
183 }
184
185 // Interface name constants.
186 const (
187 InterfaceDbusmenu = "com.canonical.dbusmenu"
188 )
189
190 // Dbusmenuer is com.canonical.dbusmenu interface.
191 type Dbusmenuer interface {
192 // GetLayout is com.canonical.dbusmenu.GetLayout method.
193 GetLayout(parentId int32, recursionDepth int32, propertyNames []string) (revision uint32, layout struct {
194 V0 int32
195 V1 map[string]dbus.Variant
196 V2 []dbus.Variant
197 }, err *dbus.Error)
198 // GetGroupProperties is com.canonical.dbusmenu.GetGroupProperties method.
199 GetGroupProperties(ids []int32, propertyNames []string) (properties []struct {
200 V0 int32
201 V1 map[string]dbus.Variant
202 }, err *dbus.Error)
203 // GetProperty is com.canonical.dbusmenu.GetProperty method.
204 GetProperty(id int32, name string) (value dbus.Variant, err *dbus.Error)
205 // Event is com.canonical.dbusmenu.Event method.
206 Event(id int32, eventId string, data dbus.Variant, timestamp uint32) (err *dbus.Error)
207 // EventGroup is com.canonical.dbusmenu.EventGroup method.
208 EventGroup(events []struct {
209 V0 int32
210 V1 string
211 V2 dbus.Variant
212 V3 uint32
213 }) (idErrors []int32, err *dbus.Error)
214 // AboutToShow is com.canonical.dbusmenu.AboutToShow method.
215 AboutToShow(id int32) (needUpdate bool, err *dbus.Error)
216 // AboutToShowGroup is com.canonical.dbusmenu.AboutToShowGroup method.
217 AboutToShowGroup(ids []int32) (updatesNeeded []int32, idErrors []int32, err *dbus.Error)
218 }
219
220 // ExportDbusmenu exports the given object that implements com.canonical.dbusmenu on the bus.
221 func ExportDbusmenu(conn *dbus.Conn, path dbus.ObjectPath, v Dbusmenuer) error {
222 return conn.ExportSubtreeMethodTable(map[string]interface{}{
223 "GetLayout": v.GetLayout,
224 "GetGroupProperties": v.GetGroupProperties,
225 "GetProperty": v.GetProperty,
226 "Event": v.Event,
227 "EventGroup": v.EventGroup,
228 "AboutToShow": v.AboutToShow,
229 "AboutToShowGroup": v.AboutToShowGroup,
230 }, path, InterfaceDbusmenu)
231 }
232
233 // UnexportDbusmenu unexports com.canonical.dbusmenu interface on the named path.
234 func UnexportDbusmenu(conn *dbus.Conn, path dbus.ObjectPath) error {
235 return conn.Export(nil, path, InterfaceDbusmenu)
236 }
237
238 // UnimplementedDbusmenu can be embedded to have forward compatible server implementations.
239 type UnimplementedDbusmenu struct{}
240
241 func (*UnimplementedDbusmenu) iface() string {
242 return InterfaceDbusmenu
243 }
244
245 func (*UnimplementedDbusmenu) GetLayout(parentId int32, recursionDepth int32, propertyNames []string) (revision uint32, layout struct {
246 V0 int32
247 V1 map[string]dbus.Variant
248 V2 []dbus.Variant
249 }, err *dbus.Error) {
250 err = &dbus.ErrMsgUnknownMethod
251 return
252 }
253
254 func (*UnimplementedDbusmenu) GetGroupProperties(ids []int32, propertyNames []string) (properties []struct {
255 V0 int32
256 V1 map[string]dbus.Variant
257 }, err *dbus.Error) {
258 err = &dbus.ErrMsgUnknownMethod
259 return
260 }
261
262 func (*UnimplementedDbusmenu) GetProperty(id int32, name string) (value dbus.Variant, err *dbus.Error) {
263 err = &dbus.ErrMsgUnknownMethod
264 return
265 }
266
267 func (*UnimplementedDbusmenu) Event(id int32, eventId string, data dbus.Variant, timestamp uint32) (err *dbus.Error) {
268 err = &dbus.ErrMsgUnknownMethod
269 return
270 }
271
272 func (*UnimplementedDbusmenu) EventGroup(events []struct {
273 V0 int32
274 V1 string
275 V2 dbus.Variant
276 V3 uint32
277 }) (idErrors []int32, err *dbus.Error) {
278 err = &dbus.ErrMsgUnknownMethod
279 return
280 }
281
282 func (*UnimplementedDbusmenu) AboutToShow(id int32) (needUpdate bool, err *dbus.Error) {
283 err = &dbus.ErrMsgUnknownMethod
284 return
285 }
286
287 func (*UnimplementedDbusmenu) AboutToShowGroup(ids []int32) (updatesNeeded []int32, idErrors []int32, err *dbus.Error) {
288 err = &dbus.ErrMsgUnknownMethod
289 return
290 }
291
292 // NewDbusmenu creates and allocates com.canonical.dbusmenu.
293 func NewDbusmenu(object dbus.BusObject) *Dbusmenu {
294 return &Dbusmenu{object}
295 }
296
297 // Dbusmenu implements com.canonical.dbusmenu D-Bus interface.
298 type Dbusmenu struct {
299 object dbus.BusObject
300 }
301
302 // GetLayout calls com.canonical.dbusmenu.GetLayout method.
303 func (o *Dbusmenu) GetLayout(ctx context.Context, parentId int32, recursionDepth int32, propertyNames []string) (revision uint32, layout struct {
304 V0 int32
305 V1 map[string]dbus.Variant
306 V2 []dbus.Variant
307 }, err error) {
308 err = o.object.CallWithContext(ctx, InterfaceDbusmenu+".GetLayout", 0, parentId, recursionDepth, propertyNames).Store(&revision, &layout)
309 return
310 }
311
312 // GetGroupProperties calls com.canonical.dbusmenu.GetGroupProperties method.
313 func (o *Dbusmenu) GetGroupProperties(ctx context.Context, ids []int32, propertyNames []string) (properties []struct {
314 V0 int32
315 V1 map[string]dbus.Variant
316 }, err error) {
317 err = o.object.CallWithContext(ctx, InterfaceDbusmenu+".GetGroupProperties", 0, ids, propertyNames).Store(&properties)
318 return
319 }
320
321 // GetProperty calls com.canonical.dbusmenu.GetProperty method.
322 func (o *Dbusmenu) GetProperty(ctx context.Context, id int32, name string) (value dbus.Variant, err error) {
323 err = o.object.CallWithContext(ctx, InterfaceDbusmenu+".GetProperty", 0, id, name).Store(&value)
324 return
325 }
326
327 // Event calls com.canonical.dbusmenu.Event method.
328 func (o *Dbusmenu) Event(ctx context.Context, id int32, eventId string, data dbus.Variant, timestamp uint32) (err error) {
329 err = o.object.CallWithContext(ctx, InterfaceDbusmenu+".Event", 0, id, eventId, data, timestamp).Store()
330 return
331 }
332
333 // EventGroup calls com.canonical.dbusmenu.EventGroup method.
334 func (o *Dbusmenu) EventGroup(ctx context.Context, events []struct {
335 V0 int32
336 V1 string
337 V2 dbus.Variant
338 V3 uint32
339 }) (idErrors []int32, err error) {
340 err = o.object.CallWithContext(ctx, InterfaceDbusmenu+".EventGroup", 0, events).Store(&idErrors)
341 return
342 }
343
344 // AboutToShow calls com.canonical.dbusmenu.AboutToShow method.
345 func (o *Dbusmenu) AboutToShow(ctx context.Context, id int32) (needUpdate bool, err error) {
346 err = o.object.CallWithContext(ctx, InterfaceDbusmenu+".AboutToShow", 0, id).Store(&needUpdate)
347 return
348 }
349
350 // AboutToShowGroup calls com.canonical.dbusmenu.AboutToShowGroup method.
351 func (o *Dbusmenu) AboutToShowGroup(ctx context.Context, ids []int32) (updatesNeeded []int32, idErrors []int32, err error) {
352 err = o.object.CallWithContext(ctx, InterfaceDbusmenu+".AboutToShowGroup", 0, ids).Store(&updatesNeeded, &idErrors)
353 return
354 }
355
356 // GetVersion gets com.canonical.dbusmenu.Version property.
357 func (o *Dbusmenu) GetVersion(ctx context.Context) (version uint32, err error) {
358 err = o.object.CallWithContext(ctx, "org.freedesktop.DBus.Properties.Get", 0, InterfaceDbusmenu, "Version").Store(&version)
359 return
360 }
361
362 // GetTextDirection gets com.canonical.dbusmenu.TextDirection property.
363 func (o *Dbusmenu) GetTextDirection(ctx context.Context) (textDirection string, err error) {
364 err = o.object.CallWithContext(ctx, "org.freedesktop.DBus.Properties.Get", 0, InterfaceDbusmenu, "TextDirection").Store(&textDirection)
365 return
366 }
367
368 // GetStatus gets com.canonical.dbusmenu.Status property.
369 func (o *Dbusmenu) GetStatus(ctx context.Context) (status string, err error) {
370 err = o.object.CallWithContext(ctx, "org.freedesktop.DBus.Properties.Get", 0, InterfaceDbusmenu, "Status").Store(&status)
371 return
372 }
373
374 // GetIconThemePath gets com.canonical.dbusmenu.IconThemePath property.
375 func (o *Dbusmenu) GetIconThemePath(ctx context.Context) (iconThemePath []string, err error) {
376 err = o.object.CallWithContext(ctx, "org.freedesktop.DBus.Properties.Get", 0, InterfaceDbusmenu, "IconThemePath").Store(&iconThemePath)
377 return
378 }
379
380 // Dbusmenu_ItemsPropertiesUpdatedSignal represents com.canonical.dbusmenu.ItemsPropertiesUpdated signal.
381 type Dbusmenu_ItemsPropertiesUpdatedSignal struct {
382 sender string
383 Path dbus.ObjectPath
384 Body *Dbusmenu_ItemsPropertiesUpdatedSignalBody
385 }
386
387 // Name returns the signal's name.
388 func (s *Dbusmenu_ItemsPropertiesUpdatedSignal) Name() string {
389 return "ItemsPropertiesUpdated"
390 }
391
392 // Interface returns the signal's interface.
393 func (s *Dbusmenu_ItemsPropertiesUpdatedSignal) Interface() string {
394 return InterfaceDbusmenu
395 }
396
397 // Sender returns the signal's sender unique name.
398 func (s *Dbusmenu_ItemsPropertiesUpdatedSignal) Sender() string {
399 return s.sender
400 }
401
402 func (s *Dbusmenu_ItemsPropertiesUpdatedSignal) path() dbus.ObjectPath {
403 return s.Path
404 }
405
406 func (s *Dbusmenu_ItemsPropertiesUpdatedSignal) values() []interface{} {
407 return []interface{}{s.Body.UpdatedProps, s.Body.RemovedProps}
408 }
409
410 // Dbusmenu_ItemsPropertiesUpdatedSignalBody is body container.
411 type Dbusmenu_ItemsPropertiesUpdatedSignalBody struct {
412 UpdatedProps []struct {
413 V0 int32
414 V1 map[string]dbus.Variant
415 }
416 RemovedProps []struct {
417 V0 int32
418 V1 []string
419 }
420 }
421
422 // Dbusmenu_LayoutUpdatedSignal represents com.canonical.dbusmenu.LayoutUpdated signal.
423 type Dbusmenu_LayoutUpdatedSignal struct {
424 sender string
425 Path dbus.ObjectPath
426 Body *Dbusmenu_LayoutUpdatedSignalBody
427 }
428
429 // Name returns the signal's name.
430 func (s *Dbusmenu_LayoutUpdatedSignal) Name() string {
431 return "LayoutUpdated"
432 }
433
434 // Interface returns the signal's interface.
435 func (s *Dbusmenu_LayoutUpdatedSignal) Interface() string {
436 return InterfaceDbusmenu
437 }
438
439 // Sender returns the signal's sender unique name.
440 func (s *Dbusmenu_LayoutUpdatedSignal) Sender() string {
441 return s.sender
442 }
443
444 func (s *Dbusmenu_LayoutUpdatedSignal) path() dbus.ObjectPath {
445 return s.Path
446 }
447
448 func (s *Dbusmenu_LayoutUpdatedSignal) values() []interface{} {
449 return []interface{}{s.Body.Revision, s.Body.Parent}
450 }
451
452 // Dbusmenu_LayoutUpdatedSignalBody is body container.
453 type Dbusmenu_LayoutUpdatedSignalBody struct {
454 Revision uint32
455 Parent int32
456 }
457
458 // Dbusmenu_ItemActivationRequestedSignal represents com.canonical.dbusmenu.ItemActivationRequested signal.
459 type Dbusmenu_ItemActivationRequestedSignal struct {
460 sender string
461 Path dbus.ObjectPath
462 Body *Dbusmenu_ItemActivationRequestedSignalBody
463 }
464
465 // Name returns the signal's name.
466 func (s *Dbusmenu_ItemActivationRequestedSignal) Name() string {
467 return "ItemActivationRequested"
468 }
469
470 // Interface returns the signal's interface.
471 func (s *Dbusmenu_ItemActivationRequestedSignal) Interface() string {
472 return InterfaceDbusmenu
473 }
474
475 // Sender returns the signal's sender unique name.
476 func (s *Dbusmenu_ItemActivationRequestedSignal) Sender() string {
477 return s.sender
478 }
479
480 func (s *Dbusmenu_ItemActivationRequestedSignal) path() dbus.ObjectPath {
481 return s.Path
482 }
483
484 func (s *Dbusmenu_ItemActivationRequestedSignal) values() []interface{} {
485 return []interface{}{s.Body.Id, s.Body.Timestamp}
486 }
487
488 // Dbusmenu_ItemActivationRequestedSignalBody is body container.
489 type Dbusmenu_ItemActivationRequestedSignalBody struct {
490 Id int32
491 Timestamp uint32
492 }
493
493 lines GO