webkit_web_process_extension6/auto/
context_menu.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// from webkit-gir-files
4// DO NOT EDIT
5
6use crate::{ffi, ContextMenuItem};
7use glib::translate::*;
8
9glib::wrapper! {
10    #[doc(alias = "WebKitContextMenu")]
11    pub struct ContextMenu(Object<ffi::WebKitContextMenu, ffi::WebKitContextMenuClass>);
12
13    match fn {
14        type_ => || ffi::webkit_context_menu_get_type(),
15    }
16}
17
18impl ContextMenu {
19    #[doc(alias = "webkit_context_menu_new")]
20    pub fn new() -> ContextMenu {
21        assert_initialized_main_thread!();
22        unsafe { from_glib_full(ffi::webkit_context_menu_new()) }
23    }
24
25    #[doc(alias = "webkit_context_menu_new_with_items")]
26    #[doc(alias = "new_with_items")]
27    pub fn with_items(items: &[ContextMenuItem]) -> ContextMenu {
28        assert_initialized_main_thread!();
29        unsafe {
30            from_glib_full(ffi::webkit_context_menu_new_with_items(
31                items.to_glib_none().0,
32            ))
33        }
34    }
35
36    #[doc(alias = "webkit_context_menu_append")]
37    pub fn append(&self, item: &ContextMenuItem) {
38        unsafe {
39            ffi::webkit_context_menu_append(self.to_glib_none().0, item.to_glib_none().0);
40        }
41    }
42
43    #[doc(alias = "webkit_context_menu_first")]
44    pub fn first(&self) -> Option<ContextMenuItem> {
45        unsafe { from_glib_none(ffi::webkit_context_menu_first(self.to_glib_none().0)) }
46    }
47
48    #[doc(alias = "webkit_context_menu_get_event")]
49    #[doc(alias = "get_event")]
50    pub fn event(&self) -> Option<gdk::Event> {
51        unsafe { from_glib_none(ffi::webkit_context_menu_get_event(self.to_glib_none().0)) }
52    }
53
54    #[doc(alias = "webkit_context_menu_get_item_at_position")]
55    #[doc(alias = "get_item_at_position")]
56    pub fn item_at_position(&self, position: u32) -> Option<ContextMenuItem> {
57        unsafe {
58            from_glib_none(ffi::webkit_context_menu_get_item_at_position(
59                self.to_glib_none().0,
60                position,
61            ))
62        }
63    }
64
65    #[doc(alias = "webkit_context_menu_get_items")]
66    #[doc(alias = "get_items")]
67    pub fn items(&self) -> Vec<ContextMenuItem> {
68        unsafe {
69            FromGlibPtrContainer::from_glib_none(ffi::webkit_context_menu_get_items(
70                self.to_glib_none().0,
71            ))
72        }
73    }
74
75    #[doc(alias = "webkit_context_menu_get_n_items")]
76    #[doc(alias = "get_n_items")]
77    pub fn n_items(&self) -> u32 {
78        unsafe { ffi::webkit_context_menu_get_n_items(self.to_glib_none().0) }
79    }
80
81    #[doc(alias = "webkit_context_menu_get_user_data")]
82    #[doc(alias = "get_user_data")]
83    pub fn user_data(&self) -> Option<glib::Variant> {
84        unsafe {
85            from_glib_none(ffi::webkit_context_menu_get_user_data(
86                self.to_glib_none().0,
87            ))
88        }
89    }
90
91    #[doc(alias = "webkit_context_menu_insert")]
92    pub fn insert(&self, item: &ContextMenuItem, position: i32) {
93        unsafe {
94            ffi::webkit_context_menu_insert(self.to_glib_none().0, item.to_glib_none().0, position);
95        }
96    }
97
98    #[doc(alias = "webkit_context_menu_last")]
99    pub fn last(&self) -> Option<ContextMenuItem> {
100        unsafe { from_glib_none(ffi::webkit_context_menu_last(self.to_glib_none().0)) }
101    }
102
103    #[doc(alias = "webkit_context_menu_move_item")]
104    pub fn move_item(&self, item: &ContextMenuItem, position: i32) {
105        unsafe {
106            ffi::webkit_context_menu_move_item(
107                self.to_glib_none().0,
108                item.to_glib_none().0,
109                position,
110            );
111        }
112    }
113
114    #[doc(alias = "webkit_context_menu_prepend")]
115    pub fn prepend(&self, item: &ContextMenuItem) {
116        unsafe {
117            ffi::webkit_context_menu_prepend(self.to_glib_none().0, item.to_glib_none().0);
118        }
119    }
120
121    #[doc(alias = "webkit_context_menu_remove")]
122    pub fn remove(&self, item: &ContextMenuItem) {
123        unsafe {
124            ffi::webkit_context_menu_remove(self.to_glib_none().0, item.to_glib_none().0);
125        }
126    }
127
128    #[doc(alias = "webkit_context_menu_remove_all")]
129    pub fn remove_all(&self) {
130        unsafe {
131            ffi::webkit_context_menu_remove_all(self.to_glib_none().0);
132        }
133    }
134
135    #[doc(alias = "webkit_context_menu_set_user_data")]
136    pub fn set_user_data(&self, user_data: &glib::Variant) {
137        unsafe {
138            ffi::webkit_context_menu_set_user_data(
139                self.to_glib_none().0,
140                user_data.to_glib_none().0,
141            );
142        }
143    }
144}
145
146impl Default for ContextMenu {
147    fn default() -> Self {
148        Self::new()
149    }
150}