fixes for Bug #11199
authorFredrik Wendt <fredrik@wendt.se>
Sat, 28 Aug 2010 20:09:07 +0000 (21:09 +0100)
committerFredrik Wendt <fredrik@wendt.se>
Sat, 28 Aug 2010 20:09:07 +0000 (21:09 +0100)
package/Makefile
package/src/wifi_assistant/gui/about_dialog.py
package/test/unit/gui/about_dialog_test.py

index 743f971..e350ed8 100644 (file)
@@ -7,7 +7,7 @@
 DEBVERS := $(shell dpkg-parsechangelog | sed -n -e 's/^Version: //p')
 
 compile:
 DEBVERS := $(shell dpkg-parsechangelog | sed -n -e 's/^Version: //p')
 
 compile:
-       #perl -pi -e "s/(WimpWorks\.__init__.*?version\s*=\s*)['\"].*?['\"]/\1'${DEBVERS}'/" src/wifi-assistant/config-gui.py
+       sed -i -e 's/VERSION = .*/VERSION = "${DEBVERS}"/' src/wifi_assistant/gui/about_dialog.py
        perl -ni -e 'print; exit if /^XB-Maemo-Icon-26:$$/' debian/control
        uuencode -m share/wifi-assistant-48.png - | perl -ne 'print " $$_" unless $$. == 1 or /^====$$/' >>debian/control
        py_compilefiles `find src -type f -name '*.py'`
        perl -ni -e 'print; exit if /^XB-Maemo-Icon-26:$$/' debian/control
        uuencode -m share/wifi-assistant-48.png - | perl -ne 'print " $$_" unless $$. == 1 or /^====$$/' >>debian/control
        py_compilefiles `find src -type f -name '*.py'`
index f7cee7e..0fce196 100644 (file)
@@ -10,6 +10,8 @@ class AboutDialog():
     DONATE_BUTTON = 2
     CLOSE_BUTTON = 3
     
     DONATE_BUTTON = 2
     CLOSE_BUTTON = 3
     
+    VERSION = "0.9.1"
+    
     BUG_URL = 'http://wifi-assistant.garage.maemo.org/bugs/'
     DONATE_URL = 'http://wifi-assistant.garage.maemo.org/donate/'
 
     BUG_URL = 'http://wifi-assistant.garage.maemo.org/bugs/'
     DONATE_URL = 'http://wifi-assistant.garage.maemo.org/donate/'
 
@@ -19,7 +21,7 @@ class AboutDialog():
 
 
     def show(self):
 
 
     def show(self):
-        dialog = gtk.Dialog(_('About Wifi Jail Brekaout Assistant'), self._parent_window)
+        dialog = gtk.Dialog(_('About Wifi Assistant') + ' ' + AboutDialog.VERSION, self._parent_window)
         text = "I got tired of not being able to connect easily to networks guarded by a login page, " + \
             "so I created this app to scratch that itch. It's free to use, inspect, adapt and share, " + \
             "licensed under a BSD type license.\nI hope you enjoy it!"
         text = "I got tired of not being able to connect easily to networks guarded by a login page, " + \
             "so I created this app to scratch that itch. It's free to use, inspect, adapt and share, " + \
             "licensed under a BSD type license.\nI hope you enjoy it!"
@@ -32,8 +34,10 @@ class AboutDialog():
         dialog.add_button(_('Donate'), AboutDialog.DONATE_BUTTON)
         dialog.add_button(_('Close'), AboutDialog.CLOSE_BUTTON)
         
         dialog.add_button(_('Donate'), AboutDialog.DONATE_BUTTON)
         dialog.add_button(_('Close'), AboutDialog.CLOSE_BUTTON)
         
-        dialog.show_all()
-        result = self._runDialog(dialog)
+        self._runDialog(dialog)
+    
+        
+    def _responseCallback(self, dialog, result):
         dialog.hide()
         
         if result == AboutDialog.BUG_BUTTON:
         dialog.hide()
         
         if result == AboutDialog.BUG_BUTTON:
@@ -43,5 +47,5 @@ class AboutDialog():
     
 
     def _runDialog(self, dialog):
     
 
     def _runDialog(self, dialog):
-        result = dialog.run()
-        return result
+        dialog.connect("response", self._responseCallback)
+        dialog.show_all()
index a0966f6..a5dcdd4 100644 (file)
@@ -28,15 +28,29 @@ class AboutDialogTest(unittest.TestCase):
         self._makeRunDialogReturn(AboutDialog.DONATE_BUTTON)
         self.testee.show()
         verify(self.launcher).openUrl(AboutDialog.DONATE_URL)
         self._makeRunDialogReturn(AboutDialog.DONATE_BUTTON)
         self.testee.show()
         verify(self.launcher).openUrl(AboutDialog.DONATE_URL)
+        
+
+    def test_bug_11199_dialogTitleContainsVersion(self):
+        class checkVersionOnShow():
+            def __init__(self, version):
+                self.version = version
+            def __call__(self, dialog):
+                assert self.version in dialog.get_title()
+        
+        self.testee._runDialog = checkVersionOnShow(AboutDialog.VERSION)
+        self.testee.show()
 
 
     def _makeRunDialogReturn(self, value):
         class method():
 
 
     def _makeRunDialogReturn(self, value):
         class method():
-            def __init__(self, value_to_return):
+            def __init__(self, testee, value_to_return):
                 self._value_to_return = value_to_return
                 self._value_to_return = value_to_return
-            def __call__(self, x):
-                return self._value_to_return
-        self.testee._runDialog = method(value)
+                self._testee= testee
+            
+            def __call__(self, dialog):
+                self._testee._responseCallback(dialog, self._value_to_return)
+
+        self.testee._runDialog = method(self.testee, value)
         
     
 if __name__ == '__main__':
         
     
 if __name__ == '__main__':