|
|
|
@ -309,6 +309,7 @@ class Interface(object):
|
|
|
|
|
<toolitem action="Delete" /> |
|
|
|
|
<toolitem action="Reply" /> |
|
|
|
|
<toolitem action="Repost" /> |
|
|
|
|
<toolitem action="Favourite" /> |
|
|
|
|
<separator /> |
|
|
|
|
<toolitem action="Settings" /> |
|
|
|
|
<toolitem action="Quit" /> |
|
|
|
@ -332,6 +333,7 @@ class Interface(object):
|
|
|
|
|
<menuitem action="Delete" /> |
|
|
|
|
<menuitem action="Reply" /> |
|
|
|
|
<menuitem action="Repost" /> |
|
|
|
|
<menuitem action="Favourite" /> |
|
|
|
|
</menu> |
|
|
|
|
<menu action="Help"> |
|
|
|
|
<menuitem action="About" /> |
|
|
|
@ -425,6 +427,15 @@ class Interface(object):
|
|
|
|
|
self._repost_action.connect('activate', self._repost_message) |
|
|
|
|
action_group.add_action_with_accel(self._repost_action, '<Ctrl>p') |
|
|
|
|
|
|
|
|
|
self._favourite_action = gtk.Action('Favourite', '_Favourite', |
|
|
|
|
'Toggle the favourite status of a message', |
|
|
|
|
gtk.STOCK_ABOUT) |
|
|
|
|
self._favourite_action.set_property('sensitive', False) |
|
|
|
|
self._favourite_action.connect('activate', self._favourite_message) |
|
|
|
|
action_group.add_action_with_accel(self._favourite_action, '<Ctrl>f') |
|
|
|
|
# XXX: Not sure if "Ctrl+F" is a good option, since other applications |
|
|
|
|
# use it as "Find". |
|
|
|
|
|
|
|
|
|
# Help actions |
|
|
|
|
about_action = gtk.Action('About', '_About', 'About Mitter', |
|
|
|
|
gtk.STOCK_ABOUT) |
|
|
|
@ -587,17 +598,17 @@ class Interface(object):
|
|
|
|
|
else: |
|
|
|
|
read_status = '' |
|
|
|
|
|
|
|
|
|
if data.favourited: |
|
|
|
|
favourited = '★' |
|
|
|
|
if data.favourite: |
|
|
|
|
favourite = '★' |
|
|
|
|
else: |
|
|
|
|
favourited = '☆' |
|
|
|
|
favourite = '☆' |
|
|
|
|
|
|
|
|
|
if data.reposted_by: |
|
|
|
|
reposted_message = ' — <i>reposted by %s</i>' |
|
|
|
|
else: |
|
|
|
|
reposted_message = '' |
|
|
|
|
|
|
|
|
|
markup = MESSAGE_FORMAT % (favourited, data.name, username, |
|
|
|
|
markup = MESSAGE_FORMAT % (favourite, data.name, username, |
|
|
|
|
reposted_message, read_status, message, time) |
|
|
|
|
|
|
|
|
|
cell.set_property('markup', markup) |
|
|
|
@ -825,6 +836,8 @@ class Interface(object):
|
|
|
|
|
self._connection.can_reply(data)) |
|
|
|
|
self._repost_action.set_property('sensitive', |
|
|
|
|
self._connection.can_repost(data)) |
|
|
|
|
self._favourite_action.set_property('sensitive', |
|
|
|
|
self._connection.can_favourite(data)) |
|
|
|
|
|
|
|
|
|
return 0 |
|
|
|
|
|
|
|
|
@ -872,6 +885,25 @@ class Interface(object):
|
|
|
|
|
message) |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
def _favourite_message(self, widget, user_data=None): |
|
|
|
|
"""Toggle the favourite status of a message.""" |
|
|
|
|
(model, iter) = self._grid.get_selection().get_selected() |
|
|
|
|
message = model.get_value(iter, 0) |
|
|
|
|
|
|
|
|
|
self._favourite_iter = iter |
|
|
|
|
|
|
|
|
|
if message.favourite: |
|
|
|
|
display = 'Removing message from %s from favourites...' |
|
|
|
|
else: |
|
|
|
|
display = 'Marking message from %s as favourite...' |
|
|
|
|
self._update_status(display % (message.username)) |
|
|
|
|
|
|
|
|
|
self._threads.add_work(self._post_favourite_message, |
|
|
|
|
self._exception_favourite_message, |
|
|
|
|
self._connection.favourite, |
|
|
|
|
message) |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
def _show_settings(self, widget, user_data=None): |
|
|
|
|
"""Display the settings window.""" |
|
|
|
|
settings_window = gtk.Dialog(title='Settings', |
|
|
|
@ -1156,6 +1188,34 @@ class Interface(object):
|
|
|
|
|
error_win.hide() |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
### Results from the favourite call |
|
|
|
|
def _post_favourite_message(self, widget, data): |
|
|
|
|
"""Called when the message was favourited successfully.""" |
|
|
|
|
_log.debug('Favourite status changed.') |
|
|
|
|
message = self._grid.get_model().get_value(self._favourite_iter, 0) |
|
|
|
|
if message.favourite: |
|
|
|
|
display = 'Message unfavourited.' |
|
|
|
|
else: |
|
|
|
|
display = 'Message favourited.' |
|
|
|
|
self._update_statusbar(display) |
|
|
|
|
message.favourite = not message.favourite |
|
|
|
|
self._favourite_iter = None |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
def _exception_favourite_message(self, widget, exception): |
|
|
|
|
"""Called when the message couldn't be favourited.""" |
|
|
|
|
_log.debug('Favourite error.') |
|
|
|
|
_log.debug(str(exception)) |
|
|
|
|
|
|
|
|
|
error_win = gtk.MessageDialog(parent=self._main_window, |
|
|
|
|
type=gtk.MESSAGE_ERROR, |
|
|
|
|
message_format='Error changing favourite status of the ' \ |
|
|
|
|
'message. Please, try again.', |
|
|
|
|
buttons=gtk.BUTTONS_OK) |
|
|
|
|
error_win.run() |
|
|
|
|
error_win.hide() |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
# ------------------------------------------------------------ |
|
|
|
|
# Required functions for all interfaces |
|
|
|
|
# ------------------------------------------------------------ |
|
|
|
@ -1192,6 +1252,7 @@ class Interface(object):
|
|
|
|
|
# interthread communication. |
|
|
|
|
self._delete_iter = None |
|
|
|
|
self._reply_message_id = None |
|
|
|
|
self._favourite_iter = None |
|
|
|
|
self._new_message_count = 0 |
|
|
|
|
|
|
|
|
|
return |
|
|
|
|