[pitivi] system: Use the system instance for displaying notifications
- From: Mathieu Duponchelle <mathieudu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] system: Use the system instance for displaying notifications
- Date: Tue, 10 Dec 2013 00:08:58 +0000 (UTC)
commit 38861f742af4ce115c9265f3e7c85d8ea0f17111
Author: Alexandru Băluț <alexandru balut gmail com>
Date: Mon Dec 2 04:22:25 2013 +0100
system: Use the system instance for displaying notifications
pitivi/render.py | 14 +++-----------
pitivi/utils/system.py | 37 +++++++++++++++----------------------
2 files changed, 18 insertions(+), 33 deletions(-)
---
diff --git a/pitivi/render.py b/pitivi/render.py
index 6f88f61..761230d 100644
--- a/pitivi/render.py
+++ b/pitivi/render.py
@@ -47,12 +47,6 @@ try:
except ImportError:
has_canberra = False
-try:
- from gi.repository import Notify
- has_libnotify = True
-except ImportError:
- has_libnotify = False
-
class CachedEncoderList(object):
"""
@@ -970,11 +964,9 @@ class RenderDialog(Loggable):
self.progress.progressbar.set_text(_("Render complete"))
self.progress.window.set_title(_("Render complete"))
self.progress.setFilesizeEstimate(None)
- if has_libnotify:
- Notify.init("pitivi")
- if not self.progress.window.is_active():
- self.notification = Notify.Notification.new(_("Render complete"), _('"%s" has finished
rendering.' % self.fileentry.get_text()), "pitivi")
- self.notification.show()
+ if not self.progress.window.is_active():
+ notification = _('"%s" has finished rendering.' % self.fileentry.get_text())
+ self.app.system.desktopMessage(_("Render complete"), notification, "pitivi")
if has_canberra:
canberra = pycanberra.Canberra()
canberra.play(1, pycanberra.CA_PROP_EVENT_ID, "complete-media", None)
diff --git a/pitivi/utils/system.py b/pitivi/utils/system.py
index 9e6f60c..aed4503 100644
--- a/pitivi/utils/system.py
+++ b/pitivi/utils/system.py
@@ -26,6 +26,12 @@ from pitivi.configure import APPNAME
from pitivi.utils.loggable import Loggable
from pitivi.utils.signal import Signallable
+try:
+ from gi.repository import Notify
+ has_libnotify = True
+except ImportError:
+ has_libnotify = False
+
class System(Signallable, Loggable):
"""A base class for all *Systems
@@ -154,16 +160,14 @@ class System(Signallable, Loggable):
def uninhibitAll(self):
self._reset()
self.emit('update-power-inhibition')
- pass
def desktopMessage(self, title, message, icon=None):
"""send a message to the desktop to be displayed to the user
@arg title: C{str} the title of the message
@arg message: C{str} the body of the message
- @arg icon: C{GdkPixbuf.Pixbuf} icon to be shown with the message
+ @arg icon: C{str} icon to be shown with the message
"""
self.debug("desktopMessage(): %s, %s" % title % message)
- pass
def getUniqueFilename(self, string):
"""Get a filename which can only be obtained from the specified string.
@@ -179,18 +183,16 @@ class FreedesktopOrgSystem(System):
def __init__(self):
System.__init__(self)
- # FIXME Notifications disabled for the time being
- # Notify.init(APPNAME)
+ if has_libnotify:
+ Notify.init(APPNAME)
- def desktopMessage(self, title, message, icon=None):
+ def desktopMessage(self, title, message, icon="pitivi"):
#call super method for consistent logging
- System.desktopMessage(title, message, icon)
+ System.desktopMessage(self, title, message, icon)
- # FIXME Notifications disabled for the time being
- #notification = Notify.Notification(title, message)
- #if icon is not None and isinstance(icon, GdkPixbuf.Pixbuf):
- #notification.set_icon_from_pixbuf(icon)
- #notification.show()
+ if has_libnotify:
+ notification = Notify.Notification.new(title, message, icon=icon)
+ notification.show()
#org.gnome.SessionManager flags
@@ -275,22 +277,13 @@ system_ = None
if os.name == 'posix':
if 'GNOME_DESKTOP_SESSION_ID' in os.environ:
try:
- # FIXME Disable notifications for the time being as it causes
- # various errors and the implementation is not done yet
- #from gi.repository import Notify
import dbus
system_ = GnomeSystem
except:
pass
if system_ is None:
- try:
- # FIXME Disable notifications for the time being as it causes
- # various errors and the implementation is not done yet
- # from gi.repository import Notify
- system_ = FreedesktopOrgSystem
- except:
- pass
+ system_ = FreedesktopOrgSystem
elif os.name == 'nt':
pass
elif os.name == 'mac':
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]