[gnome-lirc-properties] Make 'Detect' button unsensitive during detection



commit 3b91ff70859a26059cbc90325527c2fc6104a322
Author: Bastien Nocera <hadess hadess net>
Date:   Wed May 19 15:04:21 2010 +0100

    Make 'Detect' button unsensitive during detection
    
    The 'Detect' button should be unsensitive during detection,
    as there's no point in running irrecord twice.
    
    This also fixes potential errors when trying to terminate
    the detection driver after it had finished, or after it failed
    to start.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=529900

 gnome_lirc_properties/ui/CustomConfiguration.py |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)
---
diff --git a/gnome_lirc_properties/ui/CustomConfiguration.py b/gnome_lirc_properties/ui/CustomConfiguration.py
index 17f0744..ef62d88 100644
--- a/gnome_lirc_properties/ui/CustomConfiguration.py
+++ b/gnome_lirc_properties/ui/CustomConfiguration.py
@@ -330,6 +330,7 @@ class CustomConfiguration(object):
                 self.__learning_driver.Release()
 
             except dbus.DBusException, ex:
+                logging.error('Error running learning driver Release')
                 logging.error(ex)
 
             try:
@@ -337,6 +338,7 @@ class CustomConfiguration(object):
                 backend.get_service().ManageLircDaemon('start')
 
             except dbus.DBusException, ex:
+                logging.error('Error restarting LIRC')
                 logging.error(ex)
 
             self.__learning_driver = None
@@ -377,7 +379,9 @@ class CustomConfiguration(object):
         def report_failure(message):
             '''Handle failures reported by the service backend.'''
 
+            self.__detection_driver = None
             self.__progressbar_detect_basics.hide()
+            self.__button_detect_basics.set_sensitive(True)
             show_message(self.__dialog, _('Remote Configuration Failed'), message)
 
             if service:
@@ -387,7 +391,9 @@ class CustomConfiguration(object):
         def report_success(result, sender=None):
             '''Handle success reported by the service backend.'''
 
+            self.__detection_driver = None
             self.__progressbar_detect_basics.hide()
+            self.__button_detect_basics.set_sensitive(True)
 
             hwdb = lirc.RemotesDatabase()
             hwdb.read(StringIO(result))
@@ -451,6 +457,7 @@ class CustomConfiguration(object):
             self.__detection_driver = driver
             self.__detection_driver.Execute()
 
+            self.__button_detect_basics.set_sensitive(False)
             self.__progressbar_detect_basics.show()
 
         except dbus.DBusException, ex:
@@ -463,11 +470,14 @@ class CustomConfiguration(object):
         try:
             if self.__detection_driver:
                 self.__detection_driver.Release()
-                self.__detection_driver = None
 
         except dbus.DBusException, ex:
+            logging.error('Error running detection driver Release')
             logging.warning(ex)
 
+        self.__detection_driver = None
+
+
     def _on_dialog_changed(self, widget = None):
         '''Handle major changes to the dialog.'''
 
@@ -628,6 +638,13 @@ class CustomConfiguration(object):
     def _on_response(self, dialog, response):
         '''Handle the dialog's "response" signal.'''
 
+        self.__stop_detection()
+        self.__stop_learning()
+
+        # Reset the progress back for detection
+        self.__progressbar_detect_basics.hide()
+        self.__button_detect_basics.set_sensitive(True)
+
         if gtk.RESPONSE_OK == response:
             try:
                 service = backend.get_service()



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]