[pkg-fso-maint] openmoko-panel-plugin and notifications

Luca Capello luca at pca.it
Wed Nov 5 14:31:33 UTC 2008


Hi Christian!

On Wed, 05 Nov 2008 13:51:15 +0100, Christian Adams wrote:
> but it should be on line 570:
>
> -        if (sendNofication):
> -            self.gsmStatusChanged = True
> -            self.sendNotification()
> +        if (sendNofication):
> +            if (notificationAvailable):
> +                self.gsmStatusChanged = True
> +                self.sendNotification()
>
> in our repo at projects.openmoko.org this error i made is fixed ..

Thank you for the fix, but please read below.

>> --8<---------------cut here---------------start------------->8---
>> diff --git a/openmoko-panel-plugin b/openmoko-panel-plugin
>> index 4493e31..c34f427 100755
>> --- a/openmoko-panel-plugin
>> +++ b/openmoko-panel-plugin
>> @@ -378,10 +378,11 @@ class StatusIcon( object ):
>>          self.icon.set_tooltip(self.getTooltip())
>>
>>      def sendNotification(self):
>> -        n = pynotify.Notification("Hardware",
>> self.getNotificationText(), "file://%s" % self.getIcon())
>> -        n.set_urgency(pynotify.URGENCY_CRITICAL)
>> -        n.set_timeout(10000) # 10 seconds timeout
>> -        n.show()
>> +        if (notificationAvailable):
[...]
> p.s:	look at the other places where self.sendNotification() is called ..
> 	i know it would be less code when the if-clause would be within the
> function itself,
> 	but i think calling the function is more expensive than avoiding
> calling it, deciding not to send the notification and returning)

While I am not an expert programmer, now that I looked at it I do not
understand why updateGSMNetworkStatus [1] acts differently from
updatePowerState [2] and updateCharge [3].  For the sake of code
consistency, I would change that to the following, successfully tested:

--8<---------------cut here---------------start------------->8---
diff --git a/openmoko-panel-plugin b/openmoko-panel-plugin
index 4493e31..ecdf73e 100755
--- a/openmoko-panel-plugin
+++ b/openmoko-panel-plugin
@@ -565,7 +565,7 @@ class GSMIcon( PowerStateIcon ):
                 self.gsmCid = self.gsmStatus[u'cid']
                 sendNofication = True
 
-        if (sendNofication):
+        if notificationAvailable:
             self.gsmStatusChanged = True
             self.sendNotification()
 
--8<---------------cut here---------------end--------------->8---

Thx, bye,
Gismo / Luca

Footnotes: 
[1] http://git.debian.org/?p=pkg-fso/openmoko-panel-plugin.git;a=blob;f=openmoko-panel-plugin;h=4493e31a4624768dbf3fdf823e9b0d79775c161e;hb=HEAD#l535
[2] http://git.debian.org/?p=pkg-fso/openmoko-panel-plugin.git;a=blob;f=openmoko-panel-plugin;h=4493e31a4624768dbf3fdf823e9b0d79775c161e;hb=HEAD#l463
[3] http://git.debian.org/?p=pkg-fso/openmoko-panel-plugin.git;a=blob;f=openmoko-panel-plugin;h=4493e31a4624768dbf3fdf823e9b0d79775c161e;hb=HEAD#l781
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 314 bytes
Desc: not available
Url : http://lists.alioth.debian.org/pipermail/pkg-fso-maint/attachments/20081105/281aecd4/attachment.pgp 


More information about the pkg-fso-maint mailing list