1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from /nix/store/39vgdpiqy94qwa8rraha7q4wcd8hdwcj-dbusmenu-gtk3-gir
// from /nix/store/ahri9v0b3c1jyls6691sjfzf2s461fzz-source
// DO NOT EDIT
use glib::{prelude::*,signal::{connect_raw, SignalHandlerId},translate::*};
use std::{boxed::Box as Box_,fmt,mem,mem::transmute};
glib::wrapper! {
#[doc(alias = "DbusmenuMenuitem")]
pub struct Menuitem(Object<ffi::DbusmenuMenuitem, ffi::DbusmenuMenuitemClass>);
match fn {
type_ => || ffi::dbusmenu_menuitem_get_type(),
}
}
impl Menuitem {
pub const NONE: Option<&'static Menuitem> = None;
/// Create a new [`Menuitem`][crate::Menuitem] with all default values.
///
/// # Returns
///
/// A newly allocated [`Menuitem`][crate::Menuitem].
#[doc(alias = "dbusmenu_menuitem_new")]
pub fn new() -> Menuitem {
assert_initialized_main_thread!();
unsafe {
from_glib_full(ffi::dbusmenu_menuitem_new())
}
}
/// This creates a blank [`Menuitem`][crate::Menuitem] with a specific ID.
/// ## `id`
/// ID to use for this menuitem
///
/// # Returns
///
/// A newly allocated [`Menuitem`][crate::Menuitem].
#[doc(alias = "dbusmenu_menuitem_new_with_id")]
#[doc(alias = "new_with_id")]
pub fn with_id(id: i32) -> Menuitem {
assert_initialized_main_thread!();
unsafe {
from_glib_full(ffi::dbusmenu_menuitem_new_with_id(id))
}
}
}
impl Default for Menuitem {
fn default() -> Self {
Self::new()
}
}
/// Trait containing all [`struct@Menuitem`] methods.
///
/// # Implementors
///
/// [`MenuitemProxy`][struct@crate::MenuitemProxy], [`Menuitem`][struct@crate::Menuitem]
pub trait MenuitemExt: 'static {
/// Puts `child` in the list of children for `self` at the location
/// specified in `position`. If there is not enough entires available
/// then `child` will be placed at the end of the list.
/// ## `child`
/// The [`Menuitem`][crate::Menuitem] to make a child of `self`.
/// ## `position`
/// Where in `self` object's list of chidren `child` should be placed.
///
/// # Returns
///
/// Whether `child` was added successfully.
#[doc(alias = "dbusmenu_menuitem_child_add_position")]
fn child_add_position(&self, child: &impl IsA<Menuitem>, position: u32) -> bool;
/// This function adds `child` to the list of children on `self` at
/// the end of that list.
/// ## `child`
/// The `DbusmenMenuitem` that will be a child
///
/// # Returns
///
/// Whether the child has been added successfully.
#[doc(alias = "dbusmenu_menuitem_child_append")]
fn child_append(&self, child: &impl IsA<Menuitem>) -> bool;
/// This function removes `child` from the children list of `self`. It does
/// not call `g_object_unref` on `child`.
/// ## `child`
/// The child [`Menuitem`][crate::Menuitem] that you want to no longer
/// be a child of `self`.
///
/// # Returns
///
/// If we were able to delete `child`.
#[doc(alias = "dbusmenu_menuitem_child_delete")]
fn child_delete(&self, child: &impl IsA<Menuitem>) -> bool;
/// Search the children of `self` to find one with the ID of `id`.
/// If it doesn't exist then we return [`None`].
/// ## `id`
/// The ID of the child that we're looking for.
///
/// # Returns
///
/// The menu item with the ID `id` or [`None`] if it
/// can't be found.
#[doc(alias = "dbusmenu_menuitem_child_find")]
#[must_use]
fn child_find(&self, id: i32) -> Option<Menuitem>;
/// This function adds `child` to the list of children on `self` at
/// the beginning of that list.
/// ## `child`
/// The `DbusmenMenuitem` that will be a child
///
/// # Returns
///
/// Whether the child has been added successfully.
#[doc(alias = "dbusmenu_menuitem_child_prepend")]
fn child_prepend(&self, child: &impl IsA<Menuitem>) -> bool;
/// This function moves a child on the list of children. It is
/// for a child that is already in the list, but simply needs a
/// new location.
/// ## `child`
/// The [`Menuitem`][crate::Menuitem] that is a child needing to be moved
/// ## `position`
/// The position in the list to place it in
///
/// # Returns
///
/// Whether the move was successful.
#[doc(alias = "dbusmenu_menuitem_child_reorder")]
fn child_reorder(&self, child: &impl IsA<Menuitem>, position: u32) -> bool;
/// This function searchs the whole tree of children that
/// are attached to `self`. This could be quite a few nodes, all
/// the way down the tree. It is a depth first search.
/// ## `id`
/// ID of the [`Menuitem`][crate::Menuitem] to search for
///
/// # Returns
///
/// The [`Menuitem`][crate::Menuitem] with the ID of `id`
/// or [`None`] if there isn't such a menu item in the tree
/// represented by `self`.
#[doc(alias = "dbusmenu_menuitem_find_id")]
#[must_use]
fn find_id(&self, id: i32) -> Option<Menuitem>;
//#[doc(alias = "dbusmenu_menuitem_foreach")]
//fn foreach(&self, func: /*Unimplemented*/Option<Basic: Pointer>, data: /*Unimplemented*/Option<Basic: Pointer>);
/// Returns simply the list of children that this menu item
/// has. The list is valid until another child related function
/// is called, where it might be changed.
///
/// # Returns
///
/// A `GList` of pointers to [`Menuitem`][crate::Menuitem] objects.
#[doc(alias = "dbusmenu_menuitem_get_children")]
#[doc(alias = "get_children")]
fn children(&self) -> Vec<Menuitem>;
/// Gets the unique ID for `self`.
///
/// # Returns
///
/// The ID of the `self`.
#[doc(alias = "dbusmenu_menuitem_get_id")]
#[doc(alias = "get_id")]
fn id(&self) -> i32;
/// This function looks up the parent of `self`
///
/// # Returns
///
/// The parent of this menu item
#[doc(alias = "dbusmenu_menuitem_get_parent")]
#[doc(alias = "get_parent")]
#[must_use]
fn parent(&self) -> Option<Menuitem>;
/// This function returns the position of the menu item `self`
/// in the children of `parent`. It will return zero if the
/// menu item can't be found.
/// ## `parent`
/// The [`Menuitem`][crate::Menuitem] who's children contain `self`
///
/// # Returns
///
/// The position of `self` in the children of `parent`.
#[doc(alias = "dbusmenu_menuitem_get_position")]
#[doc(alias = "get_position")]
fn position(&self, parent: &impl IsA<Menuitem>) -> u32;
/// This function is very similar to `dbusmenu_menuitem_get_position`
/// except that it only counts in the children that have been realized.
/// ## `parent`
/// The [`Menuitem`][crate::Menuitem] who's children contain `self`
///
/// # Returns
///
/// The position of `self` in the realized children of `parent`.
#[doc(alias = "dbusmenu_menuitem_get_position_realized")]
#[doc(alias = "get_position_realized")]
fn position_realized(&self, parent: &impl IsA<Menuitem>) -> u32;
/// This function returns the internal value of whether this is a
/// root node or not.
///
/// # Returns
///
/// [`true`] if this is a root node
#[doc(alias = "dbusmenu_menuitem_get_root")]
#[doc(alias = "get_root")]
fn is_root(&self) -> bool;
/// This function is called to create an event. It is likely
/// to be overrided by subclasses. The default menu item
/// will respond to the activate signal and do:
///
/// Emits the [`item-activate`][struct@crate::Menuitem#item-activate] signal on this
/// menu item. Called by server objects when they get the
/// appropriate DBus signals from the client.
///
/// If you subclass this function you should really think
/// about calling the parent function unless you have a good
/// reason not to.
/// ## `name`
/// The name of the signal
/// ## `variant`
/// A value that could be set for the event
/// ## `timestamp`
/// The timestamp of when the event happened
#[doc(alias = "dbusmenu_menuitem_handle_event")]
fn handle_event(&self, name: &str, variant: &glib::Variant, timestamp: u32);
//#[doc(alias = "dbusmenu_menuitem_properties_copy")]
//fn properties_copy(&self) -> /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 25 }/TypeId { ns_id: 0, id: 25 };
/// This functiong gets a list of the names of all the properties
/// that are set on this menu item. This data on the list is owned
/// by the menuitem but the list is not and should be freed using
/// `g_list_free()` when the calling function is done with it.
///
/// # Returns
///
/// A list of
/// strings or NULL if there are none.
#[doc(alias = "dbusmenu_menuitem_properties_list")]
fn properties_list(&self) -> Vec<glib::GString>;
/// Checkes to see if a particular property exists on `self` and
/// returns [`true`] if so.
/// ## `property`
/// The property to look for.
///
/// # Returns
///
/// A boolean checking to see if the property is available
#[doc(alias = "dbusmenu_menuitem_property_exist")]
fn property_exist(&self, property: &str) -> bool;
/// Look up a property on `self` and return the value of it if
/// it exits. [`None`] will be returned if the property doesn't
/// exist.
/// ## `property`
/// The property to grab.
///
/// # Returns
///
/// A string with the value of the property
/// that shouldn't be free'd. Or [`None`] if the property
/// is not set or is not a string.
#[doc(alias = "dbusmenu_menuitem_property_get")]
fn property_get(&self, property: &str) -> Option<glib::GString>;
/// Look up a property on `self` and return the value of it if
/// it exits. Returns [`false`] if the property doesn't exist.
/// ## `property`
/// The property to grab.
///
/// # Returns
///
/// The value of the property or [`false`].
#[doc(alias = "dbusmenu_menuitem_property_get_bool")]
fn property_get_bool(&self, property: &str) -> bool;
/// Look up a property on `self` and return the value of it if
/// it exits. [`None`] will be returned if the property doesn't
/// exist.
/// ## `property`
/// The property to grab.
///
/// # Returns
///
/// A byte array with the
/// value of the property that shouldn't be free'd. Or [`None`] if the property
/// is not set or is not a byte array.
#[doc(alias = "dbusmenu_menuitem_property_get_byte_array")]
fn property_get_byte_array(&self, property: &str) -> Vec<u8>;
/// Look up a property on `self` and return the value of it if
/// it exits. Returns zero if the property doesn't exist.
/// ## `property`
/// The property to grab.
///
/// # Returns
///
/// The value of the property or zero.
#[doc(alias = "dbusmenu_menuitem_property_get_int")]
fn property_get_int(&self, property: &str) -> i32;
/// Look up a property on `self` and return the value of it if
/// it exits. [`None`] will be returned if the property doesn't
/// exist.
/// ## `property`
/// The property to grab.
///
/// # Returns
///
/// A GVariant for the property.
#[doc(alias = "dbusmenu_menuitem_property_get_variant")]
fn property_get_variant(&self, property: &str) -> Option<glib::Variant>;
/// Removes a property from the menuitem.
/// ## `property`
/// The property to look for.
#[doc(alias = "dbusmenu_menuitem_property_remove")]
fn property_remove(&self, property: &str);
/// Takes the pair of `property` and `value` and places them as a
/// property on `self`. If a property already exists by that name,
/// then the value is set to the new value. If not, the property
/// is added. If the value is changed or the property was previously
/// unset then the signal [`prop-changed`][struct@crate::Menuitem#prop-changed] will be
/// emitted by this function.
/// ## `property`
/// Name of the property to set.
/// ## `value`
/// The value of the property.
///
/// # Returns
///
/// A boolean representing if the property value was set.
#[doc(alias = "dbusmenu_menuitem_property_set")]
fn property_set(&self, property: &str, value: &str) -> bool;
/// Takes a boolean `value` and sets it on `property` as a
/// property on `self`. If a property already exists by that name,
/// then the value is set to the new value. If not, the property
/// is added. If the value is changed or the property was previously
/// unset then the signal [`prop-changed`][struct@crate::Menuitem#prop-changed] will be
/// emitted by this function.
/// ## `property`
/// Name of the property to set.
/// ## `value`
/// The value of the property.
///
/// # Returns
///
/// A boolean representing if the property value was set.
#[doc(alias = "dbusmenu_menuitem_property_set_bool")]
fn property_set_bool(&self, property: &str, value: bool) -> bool;
/// Takes a byte array `value` and sets it on `property` as a
/// property on `self`. If a property already exists by that name,
/// then the value is set to the new value. If not, the property
/// is added. If the value is changed or the property was previously
/// unset then the signal [`prop-changed`][struct@crate::Menuitem#prop-changed] will be
/// emitted by this function.
/// ## `property`
/// Name of the property to set.
/// ## `value`
/// The byte array.
/// ## `nelements`
/// The number of elements in the byte array.
///
/// # Returns
///
/// A boolean representing if the property value was set.
#[doc(alias = "dbusmenu_menuitem_property_set_byte_array")]
fn property_set_byte_array(&self, property: &str, values: &[u8]) -> bool;
/// Takes a boolean `value` and sets it on `property` as a
/// property on `self`. If a property already exists by that name,
/// then the value is set to the new value. If not, the property
/// is added. If the value is changed or the property was previously
/// unset then the signal [`prop-changed`][struct@crate::Menuitem#prop-changed] will be
/// emitted by this function.
/// ## `property`
/// Name of the property to set.
/// ## `value`
/// The value of the property.
///
/// # Returns
///
/// A boolean representing if the property value was set.
#[doc(alias = "dbusmenu_menuitem_property_set_int")]
fn property_set_int(&self, property: &str, value: i32) -> bool;
/// Takes the pair of `property` and `value` and places them as a
/// property on `self`. If a property already exists by that name,
/// then the value is set to the new value. If not, the property
/// is added. If the value is changed or the property was previously
/// unset then the signal [`prop-changed`][struct@crate::Menuitem#prop-changed] will be
/// emitted by this function.
/// ## `property`
/// Name of the property to set.
/// ## `value`
/// The value of the property.
///
/// # Returns
///
/// A boolean representing if the property value was set.
#[doc(alias = "dbusmenu_menuitem_property_set_variant")]
fn property_set_variant(&self, property: &str, value: &glib::Variant) -> bool;
//#[doc(alias = "dbusmenu_menuitem_send_about_to_show")]
//fn send_about_to_show(&self, cb: /*Unimplemented*/Option<Basic: Pointer>, cb_data: /*Unimplemented*/Option<Basic: Pointer>);
/// Sets the parent of `self` to `parent`. If `self` already
/// has a parent, then this call will fail. The parent will
/// be set automatically when using the usual methods to add a
/// child menuitem, so this function should not normally be
/// called directly
/// ## `parent`
/// The new parent [`Menuitem`][crate::Menuitem]
///
/// # Returns
///
/// Whether the parent was set successfully
#[doc(alias = "dbusmenu_menuitem_set_parent")]
fn set_parent(&self, parent: &impl IsA<Menuitem>) -> bool;
/// This function sets the internal value of whether this is a
/// root node or not.
/// ## `root`
/// Whether `self` is a root node or not
#[doc(alias = "dbusmenu_menuitem_set_root")]
fn set_root(&self, root: bool);
/// Signals that this menu item should be shown to the user. If this is
/// server side the server will then take it and send it over the
/// bus.
/// ## `timestamp`
/// The time that the user requested it to be shown
#[doc(alias = "dbusmenu_menuitem_show_to_user")]
fn show_to_user(&self, timestamp: u32);
/// While the name sounds devious that's exactly what this function
/// does. It takes the list of children from the `self` and clears the
/// internal list. The calling function is now in charge of the ref's
/// on the children it has taken. A lot of responsibility involved
/// in taking children.
///
/// # Returns
///
///
/// A `GList` of pointers to [`Menuitem`][crate::Menuitem] objects.
#[doc(alias = "dbusmenu_menuitem_take_children")]
fn take_children(&self) -> Vec<Menuitem>;
/// Unparents the menu item `self`. If `self` doesn't have a
/// parent, then this call will fail. The menuitem will
/// be unparented automatically when using the usual methods
/// to delete a child menuitem, so this function should not
/// normally be called directly
///
/// # Returns
///
/// Whether the menu item was unparented successfully
#[doc(alias = "dbusmenu_menuitem_unparent")]
fn unparent(&self) -> bool;
/// Emitted when the submenu for this item
/// is about to be shown
#[doc(alias = "about-to-show")]
fn connect_about_to_show<F: Fn(&Self) -> bool + 'static>(&self, f: F) -> SignalHandlerId;
//#[doc(alias = "child-added")]
//fn connect_child_added<Unsupported or ignored types>(&self, f: F) -> SignalHandlerId;
//#[doc(alias = "child-moved")]
//fn connect_child_moved<Unsupported or ignored types>(&self, f: F) -> SignalHandlerId;
//#[doc(alias = "child-removed")]
//fn connect_child_removed<Unsupported or ignored types>(&self, f: F) -> SignalHandlerId;
/// Emitted when an event is passed through. The event is signalled
/// after handle_event is called.
/// ## `arg1`
/// Name of the event
/// ## `arg2`
/// Information passed along with the event
/// ## `arg3`
/// X11 timestamp of when the event happened
#[doc(alias = "event")]
fn connect_event<F: Fn(&Self, &str, &glib::Variant, u32) -> bool + 'static>(&self, detail: Option<&str>, f: F) -> SignalHandlerId;
/// Emitted on the objects on the server side when
/// they are signaled on the client side.
/// ## `arg1`
/// The timestamp of when it was activated
#[doc(alias = "item-activated")]
fn connect_item_activated<F: Fn(&Self, u32) + 'static>(&self, f: F) -> SignalHandlerId;
/// Emitted everytime a property on a menuitem is either
/// updated or added.
/// ## `arg1`
/// The name of the property that changed
/// ## `arg2`
/// The new value of the property
#[doc(alias = "property-changed")]
fn connect_property_changed<F: Fn(&Self, &str, &glib::Variant) + 'static>(&self, f: F) -> SignalHandlerId;
/// Emitted when the initial request for properties
/// is complete on the item. If there is a type
/// handler configured for the "type" parameter
/// that will be executed before this is signaled.
#[doc(alias = "realized")]
fn connect_realized<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
/// Signaled when the application would like the visualization
/// of this menu item shown to the user. This usually requires
/// going over the bus to get it done.
/// ## `arg1`
/// Timestamp the event happened at
#[doc(alias = "show-to-user")]
fn connect_show_to_user<F: Fn(&Self, u32) + 'static>(&self, f: F) -> SignalHandlerId;
}
impl<O: IsA<Menuitem>> MenuitemExt for O {
fn child_add_position(&self, child: &impl IsA<Menuitem>, position: u32) -> bool {
unsafe {
from_glib(ffi::dbusmenu_menuitem_child_add_position(self.as_ref().to_glib_none().0, child.as_ref().to_glib_none().0, position))
}
}
fn child_append(&self, child: &impl IsA<Menuitem>) -> bool {
unsafe {
from_glib(ffi::dbusmenu_menuitem_child_append(self.as_ref().to_glib_none().0, child.as_ref().to_glib_none().0))
}
}
fn child_delete(&self, child: &impl IsA<Menuitem>) -> bool {
unsafe {
from_glib(ffi::dbusmenu_menuitem_child_delete(self.as_ref().to_glib_none().0, child.as_ref().to_glib_none().0))
}
}
fn child_find(&self, id: i32) -> Option<Menuitem> {
unsafe {
from_glib_none(ffi::dbusmenu_menuitem_child_find(self.as_ref().to_glib_none().0, id))
}
}
fn child_prepend(&self, child: &impl IsA<Menuitem>) -> bool {
unsafe {
from_glib(ffi::dbusmenu_menuitem_child_prepend(self.as_ref().to_glib_none().0, child.as_ref().to_glib_none().0))
}
}
fn child_reorder(&self, child: &impl IsA<Menuitem>, position: u32) -> bool {
unsafe {
from_glib(ffi::dbusmenu_menuitem_child_reorder(self.as_ref().to_glib_none().0, child.as_ref().to_glib_none().0, position))
}
}
fn find_id(&self, id: i32) -> Option<Menuitem> {
unsafe {
from_glib_none(ffi::dbusmenu_menuitem_find_id(self.as_ref().to_glib_none().0, id))
}
}
//fn foreach(&self, func: /*Unimplemented*/Option<Basic: Pointer>, data: /*Unimplemented*/Option<Basic: Pointer>) {
// unsafe { TODO: call ffi:dbusmenu_menuitem_foreach() }
//}
fn children(&self) -> Vec<Menuitem> {
unsafe {
FromGlibPtrContainer::from_glib_none(ffi::dbusmenu_menuitem_get_children(self.as_ref().to_glib_none().0))
}
}
fn id(&self) -> i32 {
unsafe {
ffi::dbusmenu_menuitem_get_id(self.as_ref().to_glib_none().0)
}
}
fn parent(&self) -> Option<Menuitem> {
unsafe {
from_glib_none(ffi::dbusmenu_menuitem_get_parent(self.as_ref().to_glib_none().0))
}
}
fn position(&self, parent: &impl IsA<Menuitem>) -> u32 {
unsafe {
ffi::dbusmenu_menuitem_get_position(self.as_ref().to_glib_none().0, parent.as_ref().to_glib_none().0)
}
}
fn position_realized(&self, parent: &impl IsA<Menuitem>) -> u32 {
unsafe {
ffi::dbusmenu_menuitem_get_position_realized(self.as_ref().to_glib_none().0, parent.as_ref().to_glib_none().0)
}
}
fn is_root(&self) -> bool {
unsafe {
from_glib(ffi::dbusmenu_menuitem_get_root(self.as_ref().to_glib_none().0))
}
}
fn handle_event(&self, name: &str, variant: &glib::Variant, timestamp: u32) {
unsafe {
ffi::dbusmenu_menuitem_handle_event(self.as_ref().to_glib_none().0, name.to_glib_none().0, variant.to_glib_none().0, timestamp);
}
}
//fn properties_copy(&self) -> /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 25 }/TypeId { ns_id: 0, id: 25 } {
// unsafe { TODO: call ffi:dbusmenu_menuitem_properties_copy() }
//}
fn properties_list(&self) -> Vec<glib::GString> {
unsafe {
FromGlibPtrContainer::from_glib_container(ffi::dbusmenu_menuitem_properties_list(self.as_ref().to_glib_none().0))
}
}
fn property_exist(&self, property: &str) -> bool {
unsafe {
from_glib(ffi::dbusmenu_menuitem_property_exist(const_override(self.as_ref().to_glib_none().0), property.to_glib_none().0))
}
}
fn property_get(&self, property: &str) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::dbusmenu_menuitem_property_get(const_override(self.as_ref().to_glib_none().0), property.to_glib_none().0))
}
}
fn property_get_bool(&self, property: &str) -> bool {
unsafe {
from_glib(ffi::dbusmenu_menuitem_property_get_bool(const_override(self.as_ref().to_glib_none().0), property.to_glib_none().0))
}
}
fn property_get_byte_array(&self, property: &str) -> Vec<u8> {
unsafe {
let mut nelements = mem::MaybeUninit::uninit();
let ret = FromGlibContainer::from_glib_none_num(ffi::dbusmenu_menuitem_property_get_byte_array(const_override(self.as_ref().to_glib_none().0), property.to_glib_none().0, nelements.as_mut_ptr()), nelements.assume_init() as _);
ret
}
}
fn property_get_int(&self, property: &str) -> i32 {
unsafe {
ffi::dbusmenu_menuitem_property_get_int(const_override(self.as_ref().to_glib_none().0), property.to_glib_none().0)
}
}
fn property_get_variant(&self, property: &str) -> Option<glib::Variant> {
unsafe {
from_glib_none(ffi::dbusmenu_menuitem_property_get_variant(const_override(self.as_ref().to_glib_none().0), property.to_glib_none().0))
}
}
fn property_remove(&self, property: &str) {
unsafe {
ffi::dbusmenu_menuitem_property_remove(self.as_ref().to_glib_none().0, property.to_glib_none().0);
}
}
fn property_set(&self, property: &str, value: &str) -> bool {
unsafe {
from_glib(ffi::dbusmenu_menuitem_property_set(self.as_ref().to_glib_none().0, property.to_glib_none().0, value.to_glib_none().0))
}
}
fn property_set_bool(&self, property: &str, value: bool) -> bool {
unsafe {
from_glib(ffi::dbusmenu_menuitem_property_set_bool(self.as_ref().to_glib_none().0, property.to_glib_none().0, value.into_glib()))
}
}
fn property_set_byte_array(&self, property: &str, values: &[u8]) -> bool {
unsafe {
from_glib(ffi::dbusmenu_menuitem_property_set_byte_array(self.as_ref().to_glib_none().0, property.to_glib_none().0, values.as_ptr(), values.len()))
}
}
fn property_set_int(&self, property: &str, value: i32) -> bool {
unsafe {
from_glib(ffi::dbusmenu_menuitem_property_set_int(self.as_ref().to_glib_none().0, property.to_glib_none().0, value))
}
}
fn property_set_variant(&self, property: &str, value: &glib::Variant) -> bool {
unsafe {
from_glib(ffi::dbusmenu_menuitem_property_set_variant(self.as_ref().to_glib_none().0, property.to_glib_none().0, value.to_glib_none().0))
}
}
//fn send_about_to_show(&self, cb: /*Unimplemented*/Option<Basic: Pointer>, cb_data: /*Unimplemented*/Option<Basic: Pointer>) {
// unsafe { TODO: call ffi:dbusmenu_menuitem_send_about_to_show() }
//}
fn set_parent(&self, parent: &impl IsA<Menuitem>) -> bool {
unsafe {
from_glib(ffi::dbusmenu_menuitem_set_parent(self.as_ref().to_glib_none().0, parent.as_ref().to_glib_none().0))
}
}
fn set_root(&self, root: bool) {
unsafe {
ffi::dbusmenu_menuitem_set_root(self.as_ref().to_glib_none().0, root.into_glib());
}
}
fn show_to_user(&self, timestamp: u32) {
unsafe {
ffi::dbusmenu_menuitem_show_to_user(self.as_ref().to_glib_none().0, timestamp);
}
}
fn take_children(&self) -> Vec<Menuitem> {
unsafe {
FromGlibPtrContainer::from_glib_full(ffi::dbusmenu_menuitem_take_children(self.as_ref().to_glib_none().0))
}
}
fn unparent(&self) -> bool {
unsafe {
from_glib(ffi::dbusmenu_menuitem_unparent(self.as_ref().to_glib_none().0))
}
}
fn connect_about_to_show<F: Fn(&Self) -> bool + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn about_to_show_trampoline<P: IsA<Menuitem>, F: Fn(&P) -> bool + 'static>(this: *mut ffi::DbusmenuMenuitem, f: glib::ffi::gpointer) -> glib::ffi::gboolean {
let f: &F = &*(f as *const F);
f(Menuitem::from_glib_borrow(this).unsafe_cast_ref()).into_glib()
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"about-to-show\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(about_to_show_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
}
}
//fn connect_child_added<Unsupported or ignored types>(&self, f: F) -> SignalHandlerId {
// Ignored arg1: GObject.Object
//}
//fn connect_child_moved<Unsupported or ignored types>(&self, f: F) -> SignalHandlerId {
// Ignored arg1: GObject.Object
//}
//fn connect_child_removed<Unsupported or ignored types>(&self, f: F) -> SignalHandlerId {
// Ignored arg1: GObject.Object
//}
fn connect_event<F: Fn(&Self, &str, &glib::Variant, u32) -> bool + 'static>(&self, detail: Option<&str>, f: F) -> SignalHandlerId {
unsafe extern "C" fn event_trampoline<P: IsA<Menuitem>, F: Fn(&P, &str, &glib::Variant, u32) -> bool + 'static>(this: *mut ffi::DbusmenuMenuitem, arg1: *mut libc::c_char, arg2: *mut glib::ffi::GVariant, arg3: libc::c_uint, f: glib::ffi::gpointer) -> glib::ffi::gboolean {
let f: &F = &*(f as *const F);
f(Menuitem::from_glib_borrow(this).unsafe_cast_ref(), &glib::GString::from_glib_borrow(arg1), &from_glib_borrow(arg2), arg3).into_glib()
}
unsafe {
let f: Box_<F> = Box_::new(f);
let detailed_signal_name = detail.map(|name| { format!("event::{name}\0") });
let signal_name: &[u8] = detailed_signal_name.as_ref().map_or(&b"event\0"[..], |n| n.as_bytes());
connect_raw(self.as_ptr() as *mut _, signal_name.as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(event_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
}
}
fn connect_item_activated<F: Fn(&Self, u32) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn item_activated_trampoline<P: IsA<Menuitem>, F: Fn(&P, u32) + 'static>(this: *mut ffi::DbusmenuMenuitem, arg1: libc::c_uint, f: glib::ffi::gpointer) {
let f: &F = &*(f as *const F);
f(Menuitem::from_glib_borrow(this).unsafe_cast_ref(), arg1)
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"item-activated\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(item_activated_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
}
}
fn connect_property_changed<F: Fn(&Self, &str, &glib::Variant) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn property_changed_trampoline<P: IsA<Menuitem>, F: Fn(&P, &str, &glib::Variant) + 'static>(this: *mut ffi::DbusmenuMenuitem, arg1: *mut libc::c_char, arg2: *mut glib::ffi::GVariant, f: glib::ffi::gpointer) {
let f: &F = &*(f as *const F);
f(Menuitem::from_glib_borrow(this).unsafe_cast_ref(), &glib::GString::from_glib_borrow(arg1), &from_glib_borrow(arg2))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"property-changed\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(property_changed_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
}
}
fn connect_realized<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn realized_trampoline<P: IsA<Menuitem>, F: Fn(&P) + 'static>(this: *mut ffi::DbusmenuMenuitem, f: glib::ffi::gpointer) {
let f: &F = &*(f as *const F);
f(Menuitem::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"realized\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(realized_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
}
}
fn connect_show_to_user<F: Fn(&Self, u32) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn show_to_user_trampoline<P: IsA<Menuitem>, F: Fn(&P, u32) + 'static>(this: *mut ffi::DbusmenuMenuitem, arg1: libc::c_uint, f: glib::ffi::gpointer) {
let f: &F = &*(f as *const F);
f(Menuitem::from_glib_borrow(this).unsafe_cast_ref(), arg1)
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"show-to-user\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(show_to_user_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
}
}
}
impl fmt::Display for Menuitem {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("Menuitem")
}
}