Browse Source

Message actions are now sensitive to the user's own messages

master
Julio Biason 15 years ago
parent
commit
91b6dbfa83
  1. 52
      mitterlib/ui/ui_pygtk.py

52
mitterlib/ui/ui_pygtk.py

@ -267,8 +267,8 @@ class Interface(object):
self._grid.append_column(message_column)
self._grid.set_resize_mode(gtk.RESIZE_IMMEDIATE)
#self.grid.connect('cursor-changed', self.check_post)
#self.grid.connect('row-activated', self.open_post)
self._grid.connect('cursor-changed', self._message_selected)
#self._grid.connect('row-activated', self.open_post)
#self.grid.connect('button-press-event', self.click_post)
#self.grid.connect('popup-menu',
# lambda view: self.show_post_popup(view, None))
@ -287,6 +287,7 @@ class Interface(object):
<ui>
<toolbar name="MainToolbar">
<toolitem action="Refresh" />
<toolitem action="Clear" />
<separator />
<toolitem action="Delete" />
<toolitem action="Reply" />
@ -302,6 +303,7 @@ class Interface(object):
<menu action="Edit">
<menuitem action="Refresh" />
<menuitem action="Update" />
<menuitem action="Clear" />
<menuitem action="ShrinkURL" />
<menuitem action="MuteNotify" />
<separator />
@ -348,7 +350,7 @@ class Interface(object):
refresh_action = gtk.Action('Refresh', '_Refresh',
'Update the listing', gtk.STOCK_REFRESH)
#refresh_action.connect('activate', self.refresh)
action_group.add_action_with_accel(refresh_action, 'F5')
action_group.add_action_with_accel(refresh_action, None)
self._update_action = gtk.Action('Update', '_Update',
'Update your status', gtk.STOCK_ADD)
@ -356,6 +358,11 @@ class Interface(object):
self._update_action.connect('activate', self._update_status)
action_group.add_action_with_accel(self._update_action,
'<Ctrl>Return')
clear_action = gtk.Action('Clear', '_Clear',
'Clear the message list', gtk.STOCK_CLEAR)
action_group.add_action_with_accel(clear_action, None)
# TODO: Connect
#shrink_url_action = gtk.Action('ShrinkURL', 'Shrink _URL',
# 'Shrink selected URL', gtk.STOCK_EXECUTE)
@ -373,25 +380,25 @@ class Interface(object):
action_group.add_action(settings_action)
# Message actions
delete_action = gtk.Action('Delete', '_Delete', 'Delete a post',
gtk.STOCK_DELETE)
delete_action.set_property('sensitive', False)
self._delete_action = gtk.Action('Delete', '_Delete',
'Delete a post', gtk.STOCK_DELETE)
self._delete_action.set_property('sensitive', False)
#delete_action.connect('activate', self.delete_tweet)
action_group.add_action(delete_action)
action_group.add_action(self._delete_action)
reply_action = gtk.Action('Reply', '_Reply',
self._reply_action = gtk.Action('Reply', '_Reply',
"Send a response to someone's else message", gtk.STOCK_REDO)
reply_action.set_property('sensitive', False)
self._reply_action.set_property('sensitive', False)
# TODO: Connect
action_group.add_action(reply_action)
action_group.add_action(self._reply_action)
# TODO: Find a better word (non-network related) to this
retweet_action = gtk.Action('Retweet', 'Re_tweet',
self._retweet_action = gtk.Action('Retweet', 'Re_tweet',
"Put someone's else message on your timeline",
gtk.STOCK_CONVERT)
retweet_action.set_property('sensitive', False)
self._retweet_action.set_property('sensitive', False)
# TODO: Connect
action_group.add_action(retweet_action)
action_group.add_action(self._retweet_action)
# Help actions
about_action = gtk.Action('About', '_About', 'About Mitter',
@ -531,6 +538,7 @@ class Interface(object):
# use a different highlight for the current user
# TODO: How to handle this with several networks?
# SOLUTION: self._connection.is_self(message)
#message = re.sub(r'(@'+self.twitter.username+')',
# r'<span foreground="#FF6633">\1</span>',
# message)
@ -657,6 +665,24 @@ 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
cannot do."""
(model, iter) = view.get_selection().get_selected()
data = model.get_value(iter, 0)
user_owned = self._connection.is_self(data)
_log.debug('User message: %s', str(user_owned))
self._delete_action.set_property('sensitive', user_owned)
self._reply_action.set_property('sensitive', not user_owned)
self._retweet_action.set_property('sensitive', not user_owned)
return 0
# ------------------------------------------------------------
# Network related functions

Loading…
Cancel
Save