18
18
from gi .repository import Keybinder
19
19
from threading import Timer
20
20
from gi .repository import GdkPixbuf
21
+ from settings import Settings
21
22
22
23
23
24
APPINDICATOR_ID = 'micmuteindicator'
26
27
class Indicator ():
27
28
28
29
def __init__ (self ):
30
+ self .settings = Settings ()
29
31
self .indicator = appindicator .Indicator .new (APPINDICATOR_ID , self .get_current_state_icon (), appindicator .IndicatorCategory .SYSTEM_SERVICES )
30
32
self .indicator .set_status (appindicator .IndicatorStatus .ACTIVE )
31
33
self .indicator .set_menu (self .build_menu ())
@@ -41,15 +43,15 @@ def __init__(self):
41
43
def show_about_dialog (self , _ ):
42
44
aboutdialog = Gtk .AboutDialog ()
43
45
44
- authors = ["Sidnei Bernardo Junior" ]
46
+ authors = ["Sidnei Bernardo Junior" , "AXeL-dev" ]
45
47
documenters = ["Sidnei Bernardo Junior" ]
46
48
47
49
aboutdialog .set_program_name ("Microphone AppIndicator for Ubuntu" )
48
50
aboutdialog .set_comments ("AppIndicator to mute and show microphone mute status." )
49
51
aboutdialog .set_logo (GdkPixbuf .Pixbuf .new_from_file (self .get_resource ("icon.svg" )))
50
52
aboutdialog .set_authors (authors )
51
53
aboutdialog .set_documenters (documenters )
52
- aboutdialog .set_website ("https://github.com/sidneibjunior /microphone-indicator" )
54
+ aboutdialog .set_website ("https://github.com/LinuxForGeeks /microphone-indicator" )
53
55
aboutdialog .set_website_label ("Source code at GitHub" )
54
56
aboutdialog .connect ("response" , self .close_about_dialog )
55
57
@@ -85,6 +87,17 @@ def build_menu(self):
85
87
self .item_toggle .connect ('activate' , self .toggle_mic )
86
88
menu .append (self .item_toggle )
87
89
90
+ item_settings = Gtk .MenuItem ('Settings' )
91
+ menu_settings = Gtk .Menu ()
92
+ item_settings .set_submenu (menu_settings )
93
+ menu .append (item_settings )
94
+
95
+ self .item_show_notifications = Gtk .CheckMenuItem ('Show notifications' )
96
+ if self .settings .show_notifications :
97
+ self .item_show_notifications .set_active (True )
98
+ self .item_show_notifications .connect ('activate' , self .toggle_show_notifications )
99
+ menu_settings .append (self .item_show_notifications )
100
+
88
101
self .item_about = Gtk .MenuItem ('About' )
89
102
self .item_about .connect ('activate' , self .show_about_dialog )
90
103
menu .append (self .item_about )
@@ -96,6 +109,10 @@ def build_menu(self):
96
109
menu .show_all ()
97
110
return menu
98
111
112
+ def toggle_show_notifications (self , widget ):
113
+ self .settings .show_notifications = not self .settings .show_notifications
114
+ self .settings .save ()
115
+
99
116
def update_mic_state (self ):
100
117
self .update_menu_toggle_label ()
101
118
self .indicator .set_icon (self .get_current_state_icon ())
@@ -111,8 +128,10 @@ def toggle_mic(self, _):
111
128
self .update_mic_state ()
112
129
113
130
self .show_toggle_notification ()
114
-
131
+
115
132
def show_toggle_notification (self ):
133
+ if not self .settings .show_notifications :
134
+ return
116
135
self .notification = Notify .Notification .new ("Notify" )
117
136
title = ""
118
137
if self .get_current_mic_state () == "[off]" :
@@ -126,7 +145,7 @@ def show_toggle_notification(self):
126
145
# creates a timer to close the notification as the 'set_timeout' Notify method is ignored by the server.
127
146
t = Timer (1.0 , self .close_toggle_notification )
128
147
t .start ()
129
-
148
+
130
149
def close_toggle_notification (self ):
131
150
self .notification .close ()
132
151
0 commit comments