Permalink
Browse files

Extract icon choosing logic to a method

  • Loading branch information...
flavioamieiro committed Mar 14, 2010
1 parent 13b4e9d commit bf44e3e5579af88e7ee5b600ffbea2e765d591f0
Showing with 7 additions and 6 deletions.
  1. +7 −6 ui.py
View
13 ui.py
@@ -57,6 +57,11 @@ def show_menu(self, widget, button, time, data):
data.show_all()
data.popup(None, None, None, button, time)
+ def _set_icon(self):
+ self.status_icon.set_from_file(
+ PASS_ICON if self.current_status == 0 else FAIL_ICON
+ )
+
def _warn_time_is_up(self):
"""Shows a dialog warning the pilot that his time is up"""
dialog = gtk.Dialog('Dojotools', buttons=(gtk.STOCK_OK, 0))
@@ -87,9 +92,7 @@ def _show_command_results(self, status, output):
self.current_status = status
if self.timer.running:
- self.status_icon.set_from_file(
- PASS_ICON if status == 0 else FAIL_ICON
- )
+ self._set_icon()
if pynotify is not None:
pynotify.init('dojotools')
@@ -120,7 +123,5 @@ def pause_timer(self, widget=None):
self.timer.pause()
def start_timer(self, widget=None):
- self.status_icon.set_from_file(
- PASS_ICON if self.current_status == 0 else FAIL_ICON
- )
+ self._set_icon()
self.timer.start()

0 comments on commit bf44e3e

Please sign in to comment.