aboutsummaryrefslogtreecommitdiff
path: root/ParrotZikTray
diff options
context:
space:
mode:
authorMarek Siarkowicz <mareksiarkowicz@gmail.com>2015-06-13 00:14:43 +0200
committerMarek Siarkowicz <mareksiarkowicz@gmail.com>2015-06-13 00:14:43 +0200
commit2b0fb4d4f4747f991ef6abd3e26925c0e77433bb (patch)
tree519431d2fc4042ae0f4c99efd99144928a279478 /ParrotZikTray
parent2e8383760b2f32e8d068a4b235b6379cd3f06c17 (diff)
downloadpyParrotZikTCP-2b0fb4d4f4747f991ef6abd3e26925c0e77433bb.tar.xz
pyParrotZikTCP-2b0fb4d4f4747f991ef6abd3e26925c0e77433bb.zip
Refactor.
Diffstat (limited to 'ParrotZikTray')
-rwxr-xr-xParrotZikTray104
1 files changed, 33 insertions, 71 deletions
diff --git a/ParrotZikTray b/ParrotZikTray
index b955a47..45aaaf0 100755
--- a/ParrotZikTray
+++ b/ParrotZikTray
@@ -143,7 +143,39 @@ class ParrotZikBaseInterface(object):
self.auto_connection.set_active(self.parrot.auto_connection)
def refresh(self):
- raise NotImplementedError
+ if self.connected:
+ print "Updating battery"
+ self.batteryLevel = int(self.parrot.battery_level)
+
+ if self.parrot.BatteryCharging:
+ self.batteryLevel = "Charging"
+ self.indicator.setIcon("zik-battery-charging")
+ self.batteryLevel = "Unknown"
+ self.batteryState = "Charging"
+ elif self.batteryLevel > 80:
+ self.indicator.setIcon("zik-battery-100")
+ self.batteryState = "In Use"
+ elif self.batteryLevel > 60:
+ self.indicator.setIcon("zik-battery-080")
+ self.batteryState = "In Use"
+ elif self.batteryLevel > 40:
+ self.indicator.setIcon("zik-battery-060")
+ self.batteryState = "In Use"
+ elif self.batteryLevel > 20:
+ self.indicator.setIcon("zik-battery-040")
+ self.batteryState = "In Use"
+ else:
+ self.indicator.setIcon("zik-battery-low")
+ self.batteryState = "In Use"
+
+ self.indicator.info_item.set_label("Connected to: " + self.name)
+ self.firmware_version.set_label(
+ "Firmware version: " + self.version)
+ self.battery_state.set_label("State: " + self.batteryState)
+ self.battery_level.set_label(
+ "Battery Level: " + str(self.batteryLevel))
+ else:
+ self.deactivate()
class ParrotZikVersion1Interface(ParrotZikBaseInterface):
@@ -194,41 +226,6 @@ class ParrotZikVersion1Interface(ParrotZikBaseInterface):
self.parrot.concert_hall = self.concert_hall_mode.get_active()
self.concert_hall_mode.set_active(self.parrot.concert_hall)
- def refresh(self):
- if self.connected:
- print "Updating battery"
- self.batteryLevel = int(self.parrot.battery_level)
-
- if self.parrot.BatteryCharging:
- self.batteryLevel = "Charging"
- self.indicator.setIcon("zik-battery-charging")
- self.batteryLevel = "Unknown"
- self.batteryState = "Charging"
- elif self.batteryLevel > 80:
- self.indicator.setIcon("zik-battery-100")
- self.batteryState = "In Use"
- elif self.batteryLevel > 60:
- self.indicator.setIcon("zik-battery-080")
- self.batteryState = "In Use"
- elif self.batteryLevel > 40:
- self.indicator.setIcon("zik-battery-060")
- self.batteryState = "In Use"
- elif self.batteryLevel > 20:
- self.indicator.setIcon("zik-battery-040")
- self.batteryState = "In Use"
- else:
- self.indicator.setIcon("zik-battery-low")
- self.batteryState = "In Use"
-
- self.indicator.info_item.set_label("Connected to: " + self.name)
- self.firmware_version.set_label(
- "Firmware version: " + self.version)
- self.battery_state.set_label("State: " + self.batteryState)
- self.battery_level.set_label(
- "Battery Level: " + str(self.batteryLevel))
- else:
- self.deactivate()
-
class ParrotZikVersion2Interface(ParrotZikBaseInterface):
def __init__(self, indicator):
@@ -297,41 +294,6 @@ class ParrotZikVersion2Interface(ParrotZikBaseInterface):
def toggledummy(self, widget):
print(widget.get_name())
- def refresh(self):
- if self.connected:
- print "Updating battery"
- self.batteryLevel = int(self.parrot.battery_level)
-
- if self.parrot.BatteryCharging:
- self.batteryLevel = "Charging"
- self.indicator.setIcon("zik-battery-charging")
- self.batteryLevel = "Unknown"
- self.batteryState = "Charging"
- elif self.batteryLevel > 80:
- self.indicator.setIcon("zik-battery-100")
- self.batteryState = "In Use"
- elif self.batteryLevel > 60:
- self.indicator.setIcon("zik-battery-080")
- self.batteryState = "In Use"
- elif self.batteryLevel > 40:
- self.indicator.setIcon("zik-battery-060")
- self.batteryState = "In Use"
- elif self.batteryLevel > 20:
- self.indicator.setIcon("zik-battery-040")
- self.batteryState = "In Use"
- else:
- self.indicator.setIcon("zik-battery-low")
- self.batteryState = "In Use"
-
- self.indicator.info_item.set_label("Connected to: " + self.name)
- self.firmware_version.set_label(
- "Firmware version: " + self.version)
- self.battery_state.set_label("State: " + self.batteryState)
- self.battery_level.set_label(
- "Battery Level: " + str(self.batteryLevel))
- else:
- self.deactivate()
-
if __name__ == "__main__":
indicator = ParrotZikIndicator()
indicator.main()