aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xParrotZikTray104
1 files changed, 13 insertions, 91 deletions
diff --git a/ParrotZikTray b/ParrotZikTray
index 05285ef..6a4bd6b 100755
--- a/ParrotZikTray
+++ b/ParrotZikTray
@@ -6,99 +6,34 @@ import re
import os
import ParrotZik
import BluetoothPairedDevices
+from SysIndicator import *
UPDATE_FREQUENCY = 30 # seconds
-class ParrotZikIndicator:
+class ParrotZikIndicator(SysIndicator):
def __init__(self):
+
+ self.menu = UniversalMenu()
- self.menu_setup()
-
- if sys.platform=="linux2":
- import appindicator
- self.icon_directory = os.path.sep + 'usr' + os.path.sep+ 'share' + os.path.sep+'icons' + os.path.sep+'zik'+ os.path.sep
- self.statusicon = appindicator.Indicator("new-parrotzik-indicator",
- "indicator-messages",
- appindicator.CATEGORY_APPLICATION_STATUS)
- self.statusicon.set_status(appindicator.STATUS_ACTIVE)
- self.statusicon.set_icon_theme_path(self.icon_directory)
- self.statusicon.set_menu(self.menu)
- else:
- print "Win32"
- self.icon_directory = os.path.dirname(os.path.realpath(sys.argv[0])) + os.path.sep+ 'share' + os.path.sep+'icons' + os.path.sep+'zik'+ os.path.sep
- self.statusicon = gtk.StatusIcon()
- self.statusicon.connect("popup-menu", self.gtk_right_click_event)
- self.statusicon.set_tooltip("Parrot Zik")
- self.menu_shown=False
- sys.stdout = open("debug.log", "w")
- sys.stderr = open("debug.log", "w")
-
- self.setIcon("audio-headset")
- self.connected=False
-
- self.p = re.compile('90:03:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}')
-
- return
-
- def pos(menu, ignore, icon):
- return (Gtk.StatusIcon.position_menu(menu, icon))
-
- def setIcon(self, name):
- if sys.platform=="linux2":
- self.statusicon.set_icon(name)
- else:
- self.statusicon.set_from_file(self.icon_directory+name+'.png')
-
- def gtk_right_click_event(self, icon, button, time):
- if not self.menu_shown:
- self.menu_shown=True
- self.menu.popup(None, None, gtk.status_icon_position_menu, button, time, self.statusicon)
- else:
- self.menu_shown=False
- self.menu.popdown()
-
- def menu_setup(self):
- self.menu = gtk.Menu()
-
- self.info_item = gtk.MenuItem("Parrot Zik Not connected..")
- self.info_item.set_sensitive(False)
- self.info_item.show()
+ self.info_item = MenuItem("Parrot Zik Not connected..",None,sensitive = False)
self.menu.append(self.info_item)
- self.check = gtk.CheckMenuItem("Noise Cancellation")
- self.check.connect("activate", self.toggleANC)
- self.check.set_sensitive(False)
- self.check.show()
+ self.check = MenuItem("Noise Cancellation",self.toggleANC,sensitive = False, checkitem = True)
self.menu.append(self.check)
- self.check2 = gtk.CheckMenuItem("Auto Connection")
- self.check2.connect("activate", self.toggleAuto)
- self.check2.set_sensitive(False)
- self.check2.show()
+ self.check2 = MenuItem("Auto Connection",self.toggleAuto,sensitive = False, checkitem = True)
self.menu.append(self.check2)
- self.check3 = gtk.CheckMenuItem("Lou Reed Mode")
- self.check3.connect("activate", self.toggleLouReedMode)
- self.check3.set_sensitive(False)
- self.check3.show()
+ self.check3 = MenuItem("Lou Reed Mode",self.toggleLouReedMode,sensitive = False, checkitem = True)
self.menu.append(self.check3)
- self.check4 = gtk.CheckMenuItem("Concert Hall Mode")
- self.check4.connect("activate", self.toggleLouReedMode)
- self.check4.set_sensitive(False)
- self.check4.show()
+ self.check4 = MenuItem("Concert Hall Mode",self.toggleParrotConcertHall,sensitive = False, checkitem = True)
self.menu.append(self.check4)
- self.about = gtk.MenuItem()
- self.about.set_label("About")
- self.about.connect("activate", self.show_about_dialog)
- self.about.show()
- self.menu.append(self.about)
+ SysIndicator.__init__(self,icon = "audio-headset",menu = self.menu)
- self.quit_item = gtk.MenuItem("Quit")
- self.quit_item.connect("activate", self.quit)
- self.quit_item.show()
- self.menu.append(self.quit_item)
+ self.connected=False
+ self.p = re.compile('90:03:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}')
def EstablishConnection(self):
if self.connected:
@@ -233,24 +168,11 @@ class ParrotZikIndicator:
self.check4.set_sensitive(False)
return True
- def show_about_dialog(self, widget):
- about_dialog = gtk.AboutDialog()
-
- about_dialog.set_destroy_with_parent(True)
- about_dialog.set_name("Parrot Zik Tray")
- about_dialog.set_version("0.1")
- about_dialog.set_authors(["Dmitry Moiseev m0sia@m0sia.ru"])
- about_dialog.run()
- about_dialog.destroy()
-
def main(self):
self.EstablishConnection()
gtk.timeout_add(UPDATE_FREQUENCY * 1000, self.EstablishConnection)
gtk.timeout_add(UPDATE_FREQUENCY * 1000, self.CheckBattery)
- gtk.main()
-
- def quit(self, widget):
- sys.exit(0)
+ SysIndicator.main(self)
if __name__ == "__main__":
indicator = ParrotZikIndicator()