Browse Source

Repost

master
Julio Biason 15 years ago
parent
commit
26e261bb12
  1. 12
      mitterlib/network/twitter.py
  2. 33
      mitterlib/ui/ui_pygtk.py

12
mitterlib/network/twitter.py

@ -403,6 +403,12 @@ class Connection(NetworkBase):
# too large.
return TwitterNetworkData(data)
def repost(self, message):
"""Repost a message."""
body = {'id': message.id} # Force a body to make it a POST.
data = self._request('/statuses/retweet.json', body=body)
return TwitterNetworkData(data)
def delete_message(self, message):
"""Delete a message."""
if isinstance(message, NetworkData):
@ -427,6 +433,6 @@ class Connection(NetworkBase):
return True;
def can_repost(self, message):
"""Always return True; Twitter allows reposting (retweeting) to
any messages, including the ones from the user."""
return True;
"""Twitter ignores retweets from the user."""
return not (message.username ==
self._options[self.NAMESPACE]['username'])

33
mitterlib/ui/ui_pygtk.py

@ -407,9 +407,7 @@ class Interface(object):
"Put someone's else message on your timeline",
gtk.STOCK_CONVERT)
self._repost_action.set_property('sensitive', False)
# TODO: Connect
# TODO: Connecting function should indicate in the status bar that
# a repost will be made.
self._repost_action.connect('activate', self._repost_message)
action_group.add_action_with_accel(self._repost_action, '<Ctrl>p')
# Help actions
@ -558,6 +556,8 @@ class Interface(object):
# unescape escaped entities that pango is not okay with
message = re.sub(r'&', r'&amp;', message)
message = re.sub(r'<', r'&lt;', message)
message = re.sub(r'>', r'&gt;', message)
# highlight URLs
mask = r'<span foreground="%s">\1</span>' % (
@ -792,7 +792,7 @@ class Interface(object):
return
def _reply_message(self, widget, user_data=None):
"""Reply to someone's else message."""
"""Reply to someone else's message."""
(model, iter) = self._grid.get_selection().get_selected()
message = model.get_value(iter, 0)
@ -802,6 +802,18 @@ class Interface(object):
return
def _repost_message(self, widget, user_data=None):
"""Repost someone else's message on your timeline."""
(model, iter)= self._grid.get_selection().get_selected()
message = model.get_value(iter, 0)
self._update_statusbar('Reposting %s message...' %
(message.username))
self._threads.add_work(self._post_repost_message,
self._exception_repost_message,
self._connection.repost,
message)
return
# ------------------------------------------------------------
# Network related functions
# ------------------------------------------------------------
@ -896,6 +908,19 @@ class Interface(object):
_log.debug(str(exception))
return
### Results for the repost message call
def _post_repost_message(self, widget, data):
"""Called when the message is reposted successfully."""
_log.debug('Repost successful')
self._update_statusbar('Message reposted')
return
def _exception_repost_message(self, widget, exception):
"""Called when the message cannot be reposted."""
_log.debug('Repost error.')
_log.debug(str(exception))
return
# ------------------------------------------------------------
# Required functions for all interfaces
# ------------------------------------------------------------

Loading…
Cancel
Save