[postr: 2/8] Modify postr ever so slightly to accomodate for using pyunique



commit 9388d023d3835b239940cb0b80f5ff382ef00274
Author: Karl Mikaelsson <derfian lysator liu se>
Date:   Wed Feb 3 09:00:11 2010 +0100

    Modify postr ever so slightly to accomodate for using pyunique

 src/PyUnique.py |    4 +++-
 src/postr.py    |   21 ++++++++++++---------
 2 files changed, 15 insertions(+), 10 deletions(-)
---
diff --git a/src/PyUnique.py b/src/PyUnique.py
index e182671..55a93bd 100644
--- a/src/PyUnique.py
+++ b/src/PyUnique.py
@@ -1,4 +1,5 @@
 # -*- encoding: utf-8; mode: python -*-
+#
 # PyUnique, a pure python reimplementation of unique, a
 # single-instance application library.
 #
@@ -16,7 +17,8 @@
 # You should have received a copy of the GNU General Public License along with
 # this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
 # St, Fifth Floor, Boston, MA 02110-1301 USA
-
+#
+#
 
 import gobject
 import dbus
diff --git a/src/postr.py b/src/postr.py
index 754c11d..e41db32 100644
--- a/src/postr.py
+++ b/src/postr.py
@@ -45,7 +45,7 @@ from datetime import datetime
 import shelve
 
 try:
-    from gtkunique import UniqueApp
+    from PyUnique import UniqueApp, RESPONSE_OK, RESPONSE_INVALID
 except ImportError:
     from DummyUnique import UniqueApp
 
@@ -67,7 +67,7 @@ class Postr(UniqueApp):
     def __init__(self):
         UniqueApp.__init__(self, 'com.burtonini.Postr')
         try:
-            self.connect("message", self.on_message)
+            self.connect("message-received", self.on_message_pyunique)
         except AttributeError:
             pass
 
@@ -199,7 +199,10 @@ class Postr(UniqueApp):
         
         # Connect to flickr, go go go
         self.flickr.authenticate_1().addCallbacks(self.auth_open_url, self.twisted_error)
-    
+
+    def open_uri(self, uri):
+        return self.send_message(self.commands['OPEN'], uri)
+
     def twisted_error(self, failure):
         self.update_upload()
         
@@ -271,13 +274,13 @@ class Postr(UniqueApp):
         entry = TagsEntry.TagsEntry(self.flickr)
         return entry
 
-    def on_message(self, app, command, command_data, startup_id, screen, workspace):
-        """Callback from UniqueApp, when a message arrives."""
-        if command == gtkunique.OPEN:
-            self.add_image_filename(command_data)
-            return gtkunique.RESPONSE_OK
+    def on_message_pyunique(self, instance, command, data):
+        """ PyUnique callback for receiving a message """
+        if command == self.commands['OPEN']:
+            self.add_image_filename(data)
+            return RESPONSE_OK
         else:
-            return gtkunique.RESPONSE_ABORT
+            return RESPONSE_INVALID
 
     def on_model_changed(self, *args):
         # We don't care about the arguments, because we just want to know when



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]