From 13e4a6f4a105d75665e9347e4dcd90e2bc984ef6 Mon Sep 17 00:00:00 2001 From: Stephen Boyd Date: Sat, 6 Jun 2009 07:23:43 +0000 Subject: [PATCH] main: minor refactorings Simplify an if statement to just return the return value. Simplify the random and repeat button callbacks. --- sonata/main.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/sonata/main.py b/sonata/main.py index 4240a418..3b85bd22 100644 --- a/sonata/main.py +++ b/sonata/main.py @@ -2751,19 +2751,16 @@ def mpd_clear(self, _widget): mpdh.call(self.client, 'clear') self.iterate_now() + def _toggle_clicked(self, command, widget): + mpdh.call(self.client, command, int(widget.get_active())) + def on_repeat_clicked(self, widget): if self.conn: - if widget.get_active(): - mpdh.call(self.client, 'repeat', 1) - else: - mpdh.call(self.client, 'repeat', 0) + self._toggle_clicked('repeat', widget) def on_random_clicked(self, widget): if self.conn: - if widget.get_active(): - mpdh.call(self.client, 'random', 1) - else: - mpdh.call(self.client, 'random', 0) + self._toggle_clicked('random', widget) def on_prefs(self, _widget): trayicon_available = HAVE_EGG or HAVE_STATUS_ICON @@ -3000,10 +2997,7 @@ def notebook_get_tab_num(self, notebook, tabname): def notebook_tab_is_visible(self, notebook, tabname): tab = self.notebook.get_children()[self.notebook_get_tab_num(notebook, tabname)] - if tab.get_property('visible'): - return True - else: - return False + return tab.get_property('visible') def notebook_get_visible_tab_num(self, notebook, tab_num): # Get actual tab number for visible tab_num. If there is not