pcremote-client-n8x0 -> client sources
[remotepc] / pcremote-server-desktop-60 / utils / messages.py
diff --git a/pcremote-server-desktop-60/utils/messages.py b/pcremote-server-desktop-60/utils/messages.py
new file mode 100755 (executable)
index 0000000..b35cd58
--- /dev/null
@@ -0,0 +1,37 @@
+import pynotify
+import Image
+import StringIO
+import gtk
+
+class Message():
+    def __init__(self, AppName):
+        pynotify.init(AppName)
+        self.AppName = AppName
+        self.msgbox = pynotify.Notification(self.AppName, self.AppName, "PCR_on.bmp")
+        self.msgbox.set_urgency(pynotify.URGENCY_CRITICAL)
+        self.msgbox.set_timeout(5000)
+
+    def show_message(self, message):
+        self.msgbox = pynotify.Notification(self.AppName, message)
+        self.msgbox.show()
+
+    def set_image(self, img):
+#        image = Image.open(img)
+#        image = gtk.gdk.pixbuf_new_from_file(img)
+#        self.msgbox.set_icon_from_pixbuf(self.image2pixbuf(image))
+       pass
+
+    def image2pixbuf(self, img):
+       file1 = StringIO.StringIO()
+
+       img.save(file1, "ppm")
+       contents = file1.getvalue()
+       file1.close()
+
+       loader = gtk.gdk.PixbufLoader("pnm")
+       loader.write(contents, len(contents))
+
+       pixbuf = loader.get_pixbuf()
+       loader.close()
+       
+       return pixbuf