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

Loading…
Cancel
Save