From 1e5026773fe620d71a3edd5a76c103ff80ec12d0 Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Sun, 3 Jan 2010 17:17:14 -0200 Subject: [PATCH] Store and display the owner of the parent message in a reply. Closes #174 --- mitterlib/network/networkbase.py | 31 +++++++++++++++++++++---------- mitterlib/network/twitter.py | 1 + mitterlib/ui/ui_pygtk.py | 14 +++++++++----- 3 files changed, 31 insertions(+), 15 deletions(-) diff --git a/mitterlib/network/networkbase.py b/mitterlib/network/networkbase.py index 87e90e7..e600f00 100644 --- a/mitterlib/network/networkbase.py +++ b/mitterlib/network/networkbase.py @@ -107,31 +107,36 @@ class MessageTooLongWarning(NetworkWarning): class NetworkData(object): """Provides an uniform way to access information about posts. The - following fields should appear: + following fields should appear[*]_ [*]_: **id** - The message identification. + The message identification. *Optional* **name** - The name to be displayed as author of the message. + The name to be displayed as author of the message. *Required* **username** - The message author username in the network. + The message author username in the network. *Required* **avatar** - URL to the author avatar. + URL to the author avatar. *Optional* **message** - The message. + The message. *Required* **message_time** - Message timestamp (as a datetime object). Defaults to None. + Message timestamp (as a datetime object). Defaults to None. *Optional* **favourite** Boolean indicating if the message was marked as "favourite" or not. + *Optional* **parent** - The parent of this message, in case of a reply. + The parent of this message, in case of a reply. *Optional* + + **parent_owner** + Username of the owner of the parent message (in other words, "in reply + to".) *Optional* **reposted_by** Username friend of the current user that reposted that message. Some @@ -139,12 +144,17 @@ class NetworkData(object): in this case, returns the original message with the original user in a "retweeted_status" structure.) In this case, the network layer will must return the original user in *name*, *username* and *avatar*, - while the friend username will be moved to *reposted_by*. + while the friend username will be moved to *reposted_by*. *Optional* **network** The network id source of the message. Network classes don't need to worry about this field themselves; :class:`Networks` will set it when - merging information from all networks. + merging information from all networks. *Networks should **NEVER** fill + this field* + + .. [*] Not all fields need to be filled if that would require more than + one network call. + .. [*] Most networks need to be ready for some fields to not be filled. """ def __init__(self): @@ -156,6 +166,7 @@ class NetworkData(object): self.message_time = None self.favourite = False self.parent = '' + self.parent_owner = '' self.reposted_by = '' self.network = '' diff --git a/mitterlib/network/twitter.py b/mitterlib/network/twitter.py index a5cbb4e..bc6955b 100644 --- a/mitterlib/network/twitter.py +++ b/mitterlib/network/twitter.py @@ -179,6 +179,7 @@ class TwitterNetworkData(NetworkData): if 'in_reply_to_status_id' in data and data['in_reply_to_status_id']: self.parent = int(data['in_reply_to_status_id']) + self.parent_owner = data['in_reply_to_screen_name'] if 'retweeted_status' in data: self.reposted_by = self.username diff --git a/mitterlib/ui/ui_pygtk.py b/mitterlib/ui/ui_pygtk.py index e461a90..2d0f54d 100644 --- a/mitterlib/ui/ui_pygtk.py +++ b/mitterlib/ui/ui_pygtk.py @@ -604,14 +604,18 @@ class Interface(object): else: favourite = '☆' + info = [] if data.reposted_by: - reposted_message = ' — reposted by %s' % ( - data.reposted_by) - else: - reposted_message = '' + info.append(' — reposted by %s' % (data.reposted_by)) + + if data.parent_owner: + info.append(' — in reply to %s' % + (data.parent_owner)) + + info_message = ''.join(info) markup = MESSAGE_FORMAT % (favourite, full_name, username, - reposted_message, read_status, message, time) + info_message, read_status, message, time) cell.set_property('markup', markup)