1use glib::translate::ToGlibPtr;
7use libappindicator_sys::AppIndicator as AppIndicatorRaw;
8pub use libappindicator_sys::*;
9
10pub struct AppIndicator {
11 air: *mut AppIndicatorRaw,
12}
13pub enum AppIndicatorCategory {
14 ApplicationStatus = 0,
15 Communications = 1,
16 SystemServices = 2,
17 Hardware = 3,
18 Other = 4,
19}
20pub enum AppIndicatorStatus {
21 Passive = 0,
22 Active = 1,
23 Attention = 2,
24}
25impl AppIndicator {
26 pub fn new(title: &str, icon: &str) -> AppIndicator {
27 AppIndicator {
28 air: unsafe {
29 app_indicator_new(
30 title.to_glib_none().0,
31 icon.to_glib_none().0,
32 AppIndicatorCategory::ApplicationStatus as u32,
33 )
34 },
35 }
36 }
37
38 pub fn with_path(title: &str, icon: &str, theme_path: &str) -> AppIndicator {
39 AppIndicator {
40 air: unsafe {
41 app_indicator_new_with_path(
42 title.to_glib_none().0,
43 icon.to_glib_none().0,
44 AppIndicatorCategory::ApplicationStatus as u32,
45 theme_path.to_glib_none().0,
46 )
47 },
48 }
49 }
50
51 pub fn set_status(&mut self, status: AppIndicatorStatus) {
52 unsafe {
53 app_indicator_set_status(self.air, status as u32);
54 }
55 }
56
57 pub fn set_menu(&mut self, menu: &mut gtk::Menu) {
58 unsafe {
59 app_indicator_set_menu(self.air, menu.to_glib_none().0);
60 }
61 }
62
63 pub fn set_label(&mut self, label: &str, guide: &str) {
64 unsafe {
65 app_indicator_set_label(self.air, label.to_glib_none().0, guide.to_glib_none().0);
66 }
67 }
68
69 pub fn set_title(&mut self, title: &str) {
70 unsafe {
71 app_indicator_set_title(self.air, title.to_glib_none().0);
72 }
73 }
74
75 pub fn set_icon(&mut self, name: &str) {
76 unsafe {
77 app_indicator_set_icon(self.air, name.to_glib_none().0);
78 }
79 }
80 pub fn set_icon_theme_path(&mut self, path: &str) {
81 unsafe {
82 app_indicator_set_icon_theme_path(self.air, path.to_glib_none().0);
83 }
84 }
85
86 pub fn set_icon_full(&mut self, name: &str, desc: &str) {
87 unsafe {
88 app_indicator_set_icon_full(self.air, name.to_glib_none().0, desc.to_glib_none().0);
89 }
90 }
91
92 pub fn set_attention_icon(&mut self, name: &str) {
93 unsafe {
94 app_indicator_set_attention_icon(self.air, name.to_glib_none().0);
95 }
96 }
97
98 pub fn set_attention_icon_full(&mut self, name: &str, desc: &str) {
99 unsafe {
100 app_indicator_set_attention_icon_full(self.air, name.to_glib_none().0, desc.to_glib_none().0);
101 }
102 }
103}