Browse Source

Removed tailing spaces

master
Julio Biason 15 years ago
parent
commit
5d4f84d5bc
  1. 6
      mitterlib/network/__init__.py
  2. 14
      mitterlib/network/networkbase.py
  3. 18
      mitterlib/network/twitter.py
  4. 92
      mitterlib/ui/ui_pygtk.py

6
mitterlib/network/__init__.py

@ -196,7 +196,7 @@ class Networks(object):
data = self.networks[network].message(message_id)
data.network = network
return data
return data
def replies(self, network=None):
"""Return a list of NetworkData objects for the replies for the user
@ -225,11 +225,11 @@ class Networks(object):
def can_delete(self, message):
"""Return True if the message can be deleted; False otherwise."""
return self.networks[message.network].can_delete(message)
def can_reply(self, message):
"""Return True if the message can be replied; False otherwise."""
return self.networks[message.network].can_reply(message)
def can_repost(self, message):
"""Return True if the message can be resposted; False otherwise."""
return self.networks[message.network].can_repost(message)

14
mitterlib/network/networkbase.py

@ -129,7 +129,7 @@ class NetworkData(object):
**parent**
The parent of this message, in case of a reply.
**reposted_by**
Username friend of the current user that reposted that message. Some
networks will return the original user in a separate table (Twitter,
@ -196,7 +196,7 @@ class NetworkBase(object):
:class:`Networks` won't send requests to networks that return False to
this function."""
return False
def messages(self):
"""Return a list of :class:`NetworkData` objects for the main
"timeline" (the default list presented to the user.)"""
@ -211,9 +211,9 @@ class NetworkBase(object):
# TODO: All networks will return an id? If so, what we do with it
# anyway?
return None
def repost(self, message):
"""Repost a message in your current timeline. *message* must be a
"""Repost a message in your current timeline. *message* must be a
valid :class:`NetworkData` object. Must return the id of the new
message."""
# TODO: All networks will return an id? If so, what we do with it
@ -241,15 +241,15 @@ class NetworkBase(object):
capped. If such limitation doesn't exist for the network, a negative
number should be returned."""
return -1
def can_delete(self, message):
"""Return True if the message can be deleted; False otherwise."""
return False;
def can_reply(self, message):
"""Return True if the message can be replied; False otherwise."""
return False;
def can_repost(self, message):
"""Return True if the message can be resposted; False otherwise."""
return False;

18
mitterlib/network/twitter.py

@ -119,15 +119,15 @@ 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'])
if 'retweeted_status' in data:
self.reposted_by = self.username
retweet_user = data['retweeted_status']['user']
self.name = retweet_user['name']
self.username = retweet_user['screen_name']
self.avatar = retweet_user['profile_image_url']
# also switch the text for the original text.
data['text'] = data['retweeted_status']['text']
@ -154,7 +154,7 @@ class Connection(NetworkBase):
return True
else:
return False
def __init__(self, options):
self._options = options
@ -242,7 +242,7 @@ class Connection(NetworkBase):
#
# New network style methods
#
AUTH = [
{'name': 'username',
'flags': ['-u', '--username'],
@ -415,17 +415,17 @@ class Connection(NetworkBase):
_log.debug('Delete response: %s', response)
return True # Either we get a response or an exception before we reach
# this.
def can_delete(self, message):
"""Check if the message belongs to the user. If so, returns True;
"""Check if the message belongs to the user. If so, returns True;
False otherwise."""
return (message.username == self._options[self.NAMESPACE]['username'])
def can_reply(self, message):
"""Always return True; Twitter allows replying to any messages,
including the ones from the user."""
return True;
def can_repost(self, message):
"""Always return True; Twitter allows reposting (retweeting) to
any messages, including the ones from the user."""

92
mitterlib/ui/ui_pygtk.py

@ -283,7 +283,7 @@ class Interface(object):
def _create_menu_and_toolbar(self):
"""Create the main menu and the toolbar."""
# UI elements
ui_elements = '''
<ui>
@ -336,20 +336,20 @@ class Interface(object):
edit_action = gtk.Action('Edit', '_Edit', 'Edit', None)
action_group.add_action(edit_action)
message_action = gtk.Action('Message', '_Message',
message_action = gtk.Action('Message', '_Message',
'Message related options', None)
action_group.add_action(message_action)
help_action = gtk.Action('Help', '_Help', 'Help', None)
action_group.add_action(help_action)
# File actions
quit_action = gtk.Action('Quit', '_Quit',
'Exit Mitter', gtk.STOCK_QUIT)
quit_action.connect('activate', self._quit_app)
action_group.add_action_with_accel(quit_action, None)
# Edit actions
refresh_action = gtk.Action('Refresh', '_Refresh',
'Update the listing', gtk.STOCK_REFRESH)
@ -362,15 +362,15 @@ class Interface(object):
self._update_action.connect('activate', self._update_status)
action_group.add_action_with_accel(self._update_action,
'<Ctrl>Return')
self._cancel_action = gtk.Action('Cancel', '_Cancel',
'Cancel the update', gtk.STOCK_CANCEL)
self._cancel_action.set_property('sensitive', False)
self._cancel_action.connect('activate', self._clear_text)
action_group.add_action_with_accel(self._cancel_action,
'<Ctrl>Escape')
clear_action = gtk.Action('Clear', '_Clear',
clear_action = gtk.Action('Clear', '_Clear',
'Clear the message list', gtk.STOCK_CLEAR)
clear_action.connect('activate', self._clear_posts)
action_group.add_action_with_accel(clear_action, None)
@ -389,22 +389,22 @@ class Interface(object):
'Settings', gtk.STOCK_PREFERENCES)
#settings_action.connect('activate', self.show_settings)
action_group.add_action(settings_action)
# Message actions
self._delete_action = gtk.Action('Delete', '_Delete',
self._delete_action = gtk.Action('Delete', '_Delete',
'Delete a post', gtk.STOCK_DELETE)
self._delete_action.set_property('sensitive', False)
self._delete_action.connect('activate', self._delete_message)
action_group.add_action_with_accel(self._delete_action, 'Delete')
self._reply_action = gtk.Action('Reply', '_Reply',
self._reply_action = gtk.Action('Reply', '_Reply',
"Send a response to someone's else message", gtk.STOCK_REDO)
self._reply_action.set_property('sensitive', False)
self._reply_action.connect('activate', self._reply_message)
action_group.add_action_with_accel(self._reply_action, '<Ctrl>r')
self._repost_action = gtk.Action('Repost', 'Re_post',
"Put someone's else message on your timeline",
"Put someone's else message on your timeline",
gtk.STOCK_CONVERT)
self._repost_action.set_property('sensitive', False)
# TODO: Connect
@ -438,27 +438,27 @@ class Interface(object):
self._update_button = gtk.Button(label='Send')
self._update_button.connect('clicked', self._update_status)
self._update_button.set_property('sensitive', False)
self._cancel_button = gtk.Button(label='Cancel')
self._cancel_button.connect('clicked', self._clear_text)
self._cancel_button.set_property('sensitive', False)
info_box = gtk.HBox(True, 0)
self._count_label = gtk.Label()
self._count_label.set_justify(gtk.JUSTIFY_LEFT)
self._reply_label = gtk.Label()
info_box.pack_start(self._count_label, expand=True, fill=True)
info_box.pack_start(self._reply_label, expand=True, fill=True)
self._count_chars(text_buffer)
update_box = gtk.HBox(False, 0)
update_box.pack_start(self._update_text, expand=True, fill=True,
padding=0)
update_box.pack_start(self._update_button, expand=False, fill=False,
padding=0)
update_box.pack_start(self._cancel_button, expand=False, fill=False,
update_box.pack_start(self._cancel_button, expand=False, fill=False,
padding=0)
update_area = gtk.VBox(True, 0)
@ -579,7 +579,7 @@ class Interface(object):
markup = '<b>%s</b> <small>(%s)</small>:\n%s\n' \
'<small>%s</small>' % \
(data.name, username, message, time)
cell.set_property('markup', markup)
return
@ -604,7 +604,7 @@ class Interface(object):
self._cancel_button.set_property('sensitive', enabled)
self._cancel_action.set_property('sensitive', enabled)
return
def _update_statusbar(self, message):
"""Update the statusbar with the message."""
self._statusbar.push(self._statusbar_context, message)
@ -618,13 +618,13 @@ class Interface(object):
_log.debug('Dequeuing next refresh')
gobject.source_remove(self._refresh_id)
self._refresh_id = None
# do the refresh
self._update_statusbar('Retrieving messages...')
self._threads.add_work(self._post_get_messages,
self._exception_get_messages,
self._connection.messages)
# queue the next auto-refresh
interval = self._options[self.NAMESPACE]['refresh_interval']
_log.debug('Queueing next refresh in %d minutes', interval)
@ -632,13 +632,13 @@ class Interface(object):
interval * 60 * 1000,
self._refresh, None)
return
def _clear_reply(self):
"""Clear the info about a reply."""
self._reply_message_id = None
self._reply_label.set_text('')
return
def _clear_repost(self):
"""Clear the info about a repost."""
self._repost_message_id = None
@ -677,11 +677,11 @@ class Interface(object):
status=status,
reply_to=self._reply_message_id)
return
def _clear_text(self, widget):
"""Clear the text field."""
self._update_text.get_buffer().set_text('')
self._delete_iter = None
self._clear_reply()
self._clear_repost()
@ -753,35 +753,35 @@ class Interface(object):
(message2.message_time > message1.message_time):
return 1
return 0
def _message_selected(self, view, user_data=None):
"""Callback when a row in the list is selected. Mostly, we'll check
if the message is from the logged user and we change de "sensitive"
property of the message actions to reflect what the user can and
property of the message actions to reflect what the user can and
cannot do."""
(model, iter) = view.get_selection().get_selected()
data = model.get_value(iter, 0)
self._delete_action.set_property('sensitive',
self._delete_action.set_property('sensitive',
self._connection.can_delete(data))
self._reply_action.set_property('sensitive',
self._reply_action.set_property('sensitive',
self._connection.can_reply(data))
self._repost_action.set_property('sensitive',
self._repost_action.set_property('sensitive',
self._connection.can_repost(data))
return 0
def _clear_posts(self, widget, user_data=None):
"""Clear the list of posts from the grid."""
self._grid.get_model().clear()
return
def _delete_message(self, widget, user_data=None):
"""Delete a message."""
(model, iter) = self._grid.get_selection().get_selected()
message = model.get_value(iter, 0)
self._update_statusbar('Deleting message...')
self._delete_iter = iter
_log.debug('Deleting messing %d', message.id)
@ -799,13 +799,13 @@ class Interface(object):
self._reply_label.set_text('Replying to %s' % (message.username))
self._reply_message_id = message
self._update_text.grab_focus()
return
# ------------------------------------------------------------
# Network related functions
# ------------------------------------------------------------
### Results from the "messages" request
def _post_get_messages(self, widget, results):
"""Function called after the data from the messages list is
@ -879,7 +879,7 @@ class Interface(object):
_log.debug('Update error')
_log.debug(str(exception))
return
### Results for the delete message call
def _post_delete_message(self, widget, data):
"""Called when the message is deleted successfully."""
@ -889,7 +889,7 @@ class Interface(object):
self._delete_iter = None
self._update_statusbar('Message deleted.')
return
def _exception_delete_message(self, widget, exception):
"""Called when the message cannot be deleted."""
_log.debug('Delete error')
@ -930,9 +930,9 @@ class Interface(object):
self._delete_iter = None
self._reply_message_id = None
self._repost_message_id = None
return
def __call__(self):
"""Call function; displays the interface. This method should appear on
every interface."""

Loading…
Cancel
Save