|
|
|
@ -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.""" |
|
|
|
|