[X2Go-Commits] [pyhoca-gui] 02/03: Handle notification the GTK3-way. (Fixes: #769).

git-admin at x2go.org git-admin at x2go.org
Wed May 27 12:16:38 CEST 2015


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch master
in repository pyhoca-gui.

commit e44e848415eff3e4dab69e990adfc447e79143f8
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date:   Wed May 27 11:50:04 2015 +0200

    Handle notification the GTK3-way. (Fixes: #769).
---
 debian/changelog       |    3 ++-
 pyhoca/wxgui/notify.py |   19 +++++++++++++++----
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index ec3730d..0b6c3fe 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,7 @@
 pyhoca-gui (0.5.0.5-0x2go1) UNRELEASED; urgency=medium
 
-  * Continue development...
+  * New upstream version (0.5.0.5):
+    - Handle notification the GTK3-way. (Fixes: #769).
 
  -- Mike Gabriel <mike.gabriel at das-netzwerkteam.de>  Wed, 27 May 2015 11:46:24 +0200
 
diff --git a/pyhoca/wxgui/notify.py b/pyhoca/wxgui/notify.py
index bc49028..53fe93b 100644
--- a/pyhoca/wxgui/notify.py
+++ b/pyhoca/wxgui/notify.py
@@ -22,7 +22,13 @@ import wx
 from x2go import X2GOCLIENT_OS
 from x2go import log
 if X2GOCLIENT_OS in ('Linux', 'Mac'):
-    import pynotify
+    try:
+        # try the GTK3 way for notification support first...
+        from gi.repository import Notify as _Notify
+    except ImportError:
+        # GTK3 notifications are unavailable,
+        # hopefully pynotify / GTK2-based notifications are available then...
+        import pynotify as _Notify
 import exceptions
 import basepath
 
@@ -52,7 +58,7 @@ class libnotify_NotifierPopup(object):
         self._PyHocaGUI = _PyHocaGUI
         self._pyhoca_logger = self._PyHocaGUI._pyhoca_logger
 
-        if not pynotify.init("PyHocaGUI"):
+        if not _Notify.init("PyHocaGUI"):
             raise NotSupportedException
 
     def prepare(self, context, title=None, text=None, icon=None, timeout=None):
@@ -132,8 +138,13 @@ class libnotify_NotifierPopup(object):
 
         try:
             if not self._PyHocaGUI.disable_notifications and title and text:
-                n = pynotify.Notification(title, text, icon)
-                n.set_urgency(pynotify.URGENCY_NORMAL)
+                try:
+                    n = _Notify.Notification.new(title, text, icon)
+                    n.set_urgency(_Notify.Urgency.NORMAL)
+                except AttributeError:
+                    # handle pynotify / GTK2-based notifications
+                    n = _Notify.Notification(title, text, icon)
+                    n.set_urgency(_Notify.URGENCY_NORMAL)
                 n.set_timeout(timeout)
                 n.show()
         except:

--
Alioth's /srv/git/code.x2go.org/pyhoca-gui.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/pyhoca-gui.git


More information about the x2go-commits mailing list