Skip to content

Commit

Permalink
Extract icon choosing logic to a method
Browse files Browse the repository at this point in the history
  • Loading branch information
flavioamieiro committed Mar 14, 2010
1 parent 13b4e9d commit bf44e3e
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions ui.py
Expand Up @@ -57,6 +57,11 @@ def show_menu(self, widget, button, time, data):
data.show_all() data.show_all()
data.popup(None, None, None, button, time) 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): def _warn_time_is_up(self):
"""Shows a dialog warning the pilot that his time is up""" """Shows a dialog warning the pilot that his time is up"""
dialog = gtk.Dialog('Dojotools', buttons=(gtk.STOCK_OK, 0)) dialog = gtk.Dialog('Dojotools', buttons=(gtk.STOCK_OK, 0))
Expand Down Expand Up @@ -87,9 +92,7 @@ def _show_command_results(self, status, output):
self.current_status = status self.current_status = status


if self.timer.running: if self.timer.running:
self.status_icon.set_from_file( self._set_icon()
PASS_ICON if status == 0 else FAIL_ICON
)


if pynotify is not None: if pynotify is not None:
pynotify.init('dojotools') pynotify.init('dojotools')
Expand Down Expand Up @@ -120,7 +123,5 @@ def pause_timer(self, widget=None):
self.timer.pause() self.timer.pause()


def start_timer(self, widget=None): def start_timer(self, widget=None):
self.status_icon.set_from_file( self._set_icon()
PASS_ICON if self.current_status == 0 else FAIL_ICON
)
self.timer.start() self.timer.start()

0 comments on commit bf44e3e

Please sign in to comment.