Browse Source

Added favourite option and display

master
Julio Biason 15 years ago
parent
commit
997f88d5d2
  1. 8
      issues/issue-1a5111a994574de34537952ec6486cd52589e302.yaml
  2. 69
      mitterlib/ui/ui_pygtk.py

8
issues/issue-1a5111a994574de34537952ec6486cd52589e302.yaml

@ -5,8 +5,8 @@ type: :feature
component: pygtk component: pygtk
release: 1.0.0 release: 1.0.0
reporter: Julio Biason <julio.biason@gmail.com> reporter: Julio Biason <julio.biason@gmail.com>
status: :unstarted status: :closed
disposition: disposition: :fixed
creation_time: 2009-12-16 11:18:12.708128 Z creation_time: 2009-12-16 11:18:12.708128 Z
references: references:
- network-1 - network-1
@ -20,3 +20,7 @@ log_events:
- Julio Biason <julio.biason@gmail.com> - Julio Biason <julio.biason@gmail.com>
- added reference 1 - added reference 1
- "" - ""
- - 2009-12-20 21:32:03.624302 Z
- Julio Biason <julio.biason@gmail.com>
- closed with disposition fixed
- ""

69
mitterlib/ui/ui_pygtk.py

@ -309,6 +309,7 @@ class Interface(object):
<toolitem action="Delete" /> <toolitem action="Delete" />
<toolitem action="Reply" /> <toolitem action="Reply" />
<toolitem action="Repost" /> <toolitem action="Repost" />
<toolitem action="Favourite" />
<separator /> <separator />
<toolitem action="Settings" /> <toolitem action="Settings" />
<toolitem action="Quit" /> <toolitem action="Quit" />
@ -332,6 +333,7 @@ class Interface(object):
<menuitem action="Delete" /> <menuitem action="Delete" />
<menuitem action="Reply" /> <menuitem action="Reply" />
<menuitem action="Repost" /> <menuitem action="Repost" />
<menuitem action="Favourite" />
</menu> </menu>
<menu action="Help"> <menu action="Help">
<menuitem action="About" /> <menuitem action="About" />
@ -425,6 +427,15 @@ class Interface(object):
self._repost_action.connect('activate', self._repost_message) self._repost_action.connect('activate', self._repost_message)
action_group.add_action_with_accel(self._repost_action, '<Ctrl>p') 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 # Help actions
about_action = gtk.Action('About', '_About', 'About Mitter', about_action = gtk.Action('About', '_About', 'About Mitter',
gtk.STOCK_ABOUT) gtk.STOCK_ABOUT)
@ -587,17 +598,17 @@ class Interface(object):
else: else:
read_status = '' read_status = ''
if data.favourited: if data.favourite:
favourited = '&#9733;' favourite = '&#9733;'
else: else:
favourited = '&#9734;' favourite = '&#9734;'
if data.reposted_by: if data.reposted_by:
reposted_message = ' &#8212; <i>reposted by %s</i>' reposted_message = ' &#8212; <i>reposted by %s</i>'
else: else:
reposted_message = '' reposted_message = ''
markup = MESSAGE_FORMAT % (favourited, data.name, username, markup = MESSAGE_FORMAT % (favourite, data.name, username,
reposted_message, read_status, message, time) reposted_message, read_status, message, time)
cell.set_property('markup', markup) cell.set_property('markup', markup)
@ -825,6 +836,8 @@ class Interface(object):
self._connection.can_reply(data)) self._connection.can_reply(data))
self._repost_action.set_property('sensitive', self._repost_action.set_property('sensitive',
self._connection.can_repost(data)) self._connection.can_repost(data))
self._favourite_action.set_property('sensitive',
self._connection.can_favourite(data))
return 0 return 0
@ -872,6 +885,25 @@ class Interface(object):
message) message)
return 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): def _show_settings(self, widget, user_data=None):
"""Display the settings window.""" """Display the settings window."""
settings_window = gtk.Dialog(title='Settings', settings_window = gtk.Dialog(title='Settings',
@ -1156,6 +1188,34 @@ class Interface(object):
error_win.hide() error_win.hide()
return 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 # Required functions for all interfaces
# ------------------------------------------------------------ # ------------------------------------------------------------
@ -1192,6 +1252,7 @@ class Interface(object):
# interthread communication. # interthread communication.
self._delete_iter = None self._delete_iter = None
self._reply_message_id = None self._reply_message_id = None
self._favourite_iter = None
self._new_message_count = 0 self._new_message_count = 0
return return

Loading…
Cancel
Save