|
|
@ -283,7 +283,7 @@ class Interface(object): |
|
|
|
|
|
|
|
|
|
|
|
def _create_menu_and_toolbar(self): |
|
|
|
def _create_menu_and_toolbar(self): |
|
|
|
"""Create the main menu and the toolbar.""" |
|
|
|
"""Create the main menu and the toolbar.""" |
|
|
|
|
|
|
|
|
|
|
|
# UI elements |
|
|
|
# UI elements |
|
|
|
ui_elements = ''' |
|
|
|
ui_elements = ''' |
|
|
|
<ui> |
|
|
|
<ui> |
|
|
@ -336,20 +336,20 @@ class Interface(object): |
|
|
|
|
|
|
|
|
|
|
|
edit_action = gtk.Action('Edit', '_Edit', 'Edit', None) |
|
|
|
edit_action = gtk.Action('Edit', '_Edit', 'Edit', None) |
|
|
|
action_group.add_action(edit_action) |
|
|
|
action_group.add_action(edit_action) |
|
|
|
|
|
|
|
|
|
|
|
message_action = gtk.Action('Message', '_Message', |
|
|
|
message_action = gtk.Action('Message', '_Message', |
|
|
|
'Message related options', None) |
|
|
|
'Message related options', None) |
|
|
|
action_group.add_action(message_action) |
|
|
|
action_group.add_action(message_action) |
|
|
|
|
|
|
|
|
|
|
|
help_action = gtk.Action('Help', '_Help', 'Help', None) |
|
|
|
help_action = gtk.Action('Help', '_Help', 'Help', None) |
|
|
|
action_group.add_action(help_action) |
|
|
|
action_group.add_action(help_action) |
|
|
|
|
|
|
|
|
|
|
|
# File actions |
|
|
|
# File actions |
|
|
|
quit_action = gtk.Action('Quit', '_Quit', |
|
|
|
quit_action = gtk.Action('Quit', '_Quit', |
|
|
|
'Exit Mitter', gtk.STOCK_QUIT) |
|
|
|
'Exit Mitter', gtk.STOCK_QUIT) |
|
|
|
quit_action.connect('activate', self._quit_app) |
|
|
|
quit_action.connect('activate', self._quit_app) |
|
|
|
action_group.add_action_with_accel(quit_action, None) |
|
|
|
action_group.add_action_with_accel(quit_action, None) |
|
|
|
|
|
|
|
|
|
|
|
# Edit actions |
|
|
|
# Edit actions |
|
|
|
refresh_action = gtk.Action('Refresh', '_Refresh', |
|
|
|
refresh_action = gtk.Action('Refresh', '_Refresh', |
|
|
|
'Update the listing', gtk.STOCK_REFRESH) |
|
|
|
'Update the listing', gtk.STOCK_REFRESH) |
|
|
@ -362,15 +362,15 @@ 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') |
|
|
|
|
|
|
|
|
|
|
|
self._cancel_action = gtk.Action('Cancel', '_Cancel', |
|
|
|
self._cancel_action = gtk.Action('Cancel', '_Cancel', |
|
|
|
'Cancel the update', gtk.STOCK_CANCEL) |
|
|
|
'Cancel the update', gtk.STOCK_CANCEL) |
|
|
|
self._cancel_action.set_property('sensitive', False) |
|
|
|
self._cancel_action.set_property('sensitive', False) |
|
|
|
self._cancel_action.connect('activate', self._clear_text) |
|
|
|
self._cancel_action.connect('activate', self._clear_text) |
|
|
|
action_group.add_action_with_accel(self._cancel_action, |
|
|
|
action_group.add_action_with_accel(self._cancel_action, |
|
|
|
'<Ctrl>Escape') |
|
|
|
'<Ctrl>Escape') |
|
|
|
|
|
|
|
|
|
|
|
clear_action = gtk.Action('Clear', '_Clear', |
|
|
|
clear_action = gtk.Action('Clear', '_Clear', |
|
|
|
'Clear the message list', gtk.STOCK_CLEAR) |
|
|
|
'Clear the message list', gtk.STOCK_CLEAR) |
|
|
|
clear_action.connect('activate', self._clear_posts) |
|
|
|
clear_action.connect('activate', self._clear_posts) |
|
|
|
action_group.add_action_with_accel(clear_action, None) |
|
|
|
action_group.add_action_with_accel(clear_action, None) |
|
|
@ -389,22 +389,22 @@ class Interface(object): |
|
|
|
'Settings', gtk.STOCK_PREFERENCES) |
|
|
|
'Settings', gtk.STOCK_PREFERENCES) |
|
|
|
#settings_action.connect('activate', self.show_settings) |
|
|
|
#settings_action.connect('activate', self.show_settings) |
|
|
|
action_group.add_action(settings_action) |
|
|
|
action_group.add_action(settings_action) |
|
|
|
|
|
|
|
|
|
|
|
# Message actions |
|
|
|
# Message actions |
|
|
|
self._delete_action = gtk.Action('Delete', '_Delete', |
|
|
|
self._delete_action = gtk.Action('Delete', '_Delete', |
|
|
|
'Delete a post', gtk.STOCK_DELETE) |
|
|
|
'Delete a post', gtk.STOCK_DELETE) |
|
|
|
self._delete_action.set_property('sensitive', False) |
|
|
|
self._delete_action.set_property('sensitive', False) |
|
|
|
self._delete_action.connect('activate', self._delete_message) |
|
|
|
self._delete_action.connect('activate', self._delete_message) |
|
|
|
action_group.add_action_with_accel(self._delete_action, 'Delete') |
|
|
|
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) |
|
|
|
"Send a response to someone's else message", gtk.STOCK_REDO) |
|
|
|
self._reply_action.set_property('sensitive', False) |
|
|
|
self._reply_action.set_property('sensitive', False) |
|
|
|
self._reply_action.connect('activate', self._reply_message) |
|
|
|
self._reply_action.connect('activate', self._reply_message) |
|
|
|
action_group.add_action_with_accel(self._reply_action, '<Ctrl>r') |
|
|
|
action_group.add_action_with_accel(self._reply_action, '<Ctrl>r') |
|
|
|
|
|
|
|
|
|
|
|
self._repost_action = gtk.Action('Repost', 'Re_post', |
|
|
|
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) |
|
|
|
gtk.STOCK_CONVERT) |
|
|
|
self._repost_action.set_property('sensitive', False) |
|
|
|
self._repost_action.set_property('sensitive', False) |
|
|
|
# TODO: Connect |
|
|
|
# TODO: Connect |
|
|
@ -438,27 +438,27 @@ class Interface(object): |
|
|
|
self._update_button = gtk.Button(label='Send') |
|
|
|
self._update_button = gtk.Button(label='Send') |
|
|
|
self._update_button.connect('clicked', self._update_status) |
|
|
|
self._update_button.connect('clicked', self._update_status) |
|
|
|
self._update_button.set_property('sensitive', False) |
|
|
|
self._update_button.set_property('sensitive', False) |
|
|
|
|
|
|
|
|
|
|
|
self._cancel_button = gtk.Button(label='Cancel') |
|
|
|
self._cancel_button = gtk.Button(label='Cancel') |
|
|
|
self._cancel_button.connect('clicked', self._clear_text) |
|
|
|
self._cancel_button.connect('clicked', self._clear_text) |
|
|
|
self._cancel_button.set_property('sensitive', False) |
|
|
|
self._cancel_button.set_property('sensitive', False) |
|
|
|
|
|
|
|
|
|
|
|
info_box = gtk.HBox(True, 0) |
|
|
|
info_box = gtk.HBox(True, 0) |
|
|
|
self._count_label = gtk.Label() |
|
|
|
self._count_label = gtk.Label() |
|
|
|
self._count_label.set_justify(gtk.JUSTIFY_LEFT) |
|
|
|
self._count_label.set_justify(gtk.JUSTIFY_LEFT) |
|
|
|
self._reply_label = gtk.Label() |
|
|
|
self._reply_label = gtk.Label() |
|
|
|
|
|
|
|
|
|
|
|
info_box.pack_start(self._count_label, expand=True, fill=True) |
|
|
|
info_box.pack_start(self._count_label, expand=True, fill=True) |
|
|
|
info_box.pack_start(self._reply_label, expand=True, fill=True) |
|
|
|
info_box.pack_start(self._reply_label, expand=True, fill=True) |
|
|
|
|
|
|
|
|
|
|
|
self._count_chars(text_buffer) |
|
|
|
self._count_chars(text_buffer) |
|
|
|
|
|
|
|
|
|
|
|
update_box = gtk.HBox(False, 0) |
|
|
|
update_box = gtk.HBox(False, 0) |
|
|
|
update_box.pack_start(self._update_text, expand=True, fill=True, |
|
|
|
update_box.pack_start(self._update_text, expand=True, fill=True, |
|
|
|
padding=0) |
|
|
|
padding=0) |
|
|
|
update_box.pack_start(self._update_button, expand=False, fill=False, |
|
|
|
update_box.pack_start(self._update_button, expand=False, fill=False, |
|
|
|
padding=0) |
|
|
|
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) |
|
|
|
padding=0) |
|
|
|
|
|
|
|
|
|
|
|
update_area = gtk.VBox(True, 0) |
|
|
|
update_area = gtk.VBox(True, 0) |
|
|
@ -579,7 +579,7 @@ class Interface(object): |
|
|
|
markup = '<b>%s</b> <small>(%s)</small>:\n%s\n' \ |
|
|
|
markup = '<b>%s</b> <small>(%s)</small>:\n%s\n' \ |
|
|
|
'<small>%s</small>' % \ |
|
|
|
'<small>%s</small>' % \ |
|
|
|
(data.name, username, message, time) |
|
|
|
(data.name, username, message, time) |
|
|
|
|
|
|
|
|
|
|
|
cell.set_property('markup', markup) |
|
|
|
cell.set_property('markup', markup) |
|
|
|
|
|
|
|
|
|
|
|
return |
|
|
|
return |
|
|
@ -604,7 +604,7 @@ class Interface(object): |
|
|
|
self._cancel_button.set_property('sensitive', enabled) |
|
|
|
self._cancel_button.set_property('sensitive', enabled) |
|
|
|
self._cancel_action.set_property('sensitive', enabled) |
|
|
|
self._cancel_action.set_property('sensitive', enabled) |
|
|
|
return |
|
|
|
return |
|
|
|
|
|
|
|
|
|
|
|
def _update_statusbar(self, message): |
|
|
|
def _update_statusbar(self, message): |
|
|
|
"""Update the statusbar with the message.""" |
|
|
|
"""Update the statusbar with the message.""" |
|
|
|
self._statusbar.push(self._statusbar_context, message) |
|
|
|
self._statusbar.push(self._statusbar_context, message) |
|
|
@ -618,13 +618,13 @@ class Interface(object): |
|
|
|
_log.debug('Dequeuing next refresh') |
|
|
|
_log.debug('Dequeuing next refresh') |
|
|
|
gobject.source_remove(self._refresh_id) |
|
|
|
gobject.source_remove(self._refresh_id) |
|
|
|
self._refresh_id = None |
|
|
|
self._refresh_id = None |
|
|
|
|
|
|
|
|
|
|
|
# do the refresh |
|
|
|
# do the refresh |
|
|
|
self._update_statusbar('Retrieving messages...') |
|
|
|
self._update_statusbar('Retrieving messages...') |
|
|
|
self._threads.add_work(self._post_get_messages, |
|
|
|
self._threads.add_work(self._post_get_messages, |
|
|
|
self._exception_get_messages, |
|
|
|
self._exception_get_messages, |
|
|
|
self._connection.messages) |
|
|
|
self._connection.messages) |
|
|
|
|
|
|
|
|
|
|
|
# queue the next auto-refresh |
|
|
|
# queue the next auto-refresh |
|
|
|
interval = self._options[self.NAMESPACE]['refresh_interval'] |
|
|
|
interval = self._options[self.NAMESPACE]['refresh_interval'] |
|
|
|
_log.debug('Queueing next refresh in %d minutes', interval) |
|
|
|
_log.debug('Queueing next refresh in %d minutes', interval) |
|
|
@ -632,13 +632,13 @@ class Interface(object): |
|
|
|
interval * 60 * 1000, |
|
|
|
interval * 60 * 1000, |
|
|
|
self._refresh, None) |
|
|
|
self._refresh, None) |
|
|
|
return |
|
|
|
return |
|
|
|
|
|
|
|
|
|
|
|
def _clear_reply(self): |
|
|
|
def _clear_reply(self): |
|
|
|
"""Clear the info about a reply.""" |
|
|
|
"""Clear the info about a reply.""" |
|
|
|
self._reply_message_id = None |
|
|
|
self._reply_message_id = None |
|
|
|
self._reply_label.set_text('') |
|
|
|
self._reply_label.set_text('') |
|
|
|
return |
|
|
|
return |
|
|
|
|
|
|
|
|
|
|
|
def _clear_repost(self): |
|
|
|
def _clear_repost(self): |
|
|
|
"""Clear the info about a repost.""" |
|
|
|
"""Clear the info about a repost.""" |
|
|
|
self._repost_message_id = None |
|
|
|
self._repost_message_id = None |
|
|
@ -677,11 +677,11 @@ class Interface(object): |
|
|
|
status=status, |
|
|
|
status=status, |
|
|
|
reply_to=self._reply_message_id) |
|
|
|
reply_to=self._reply_message_id) |
|
|
|
return |
|
|
|
return |
|
|
|
|
|
|
|
|
|
|
|
def _clear_text(self, widget): |
|
|
|
def _clear_text(self, widget): |
|
|
|
"""Clear the text field.""" |
|
|
|
"""Clear the text field.""" |
|
|
|
self._update_text.get_buffer().set_text('') |
|
|
|
self._update_text.get_buffer().set_text('') |
|
|
|
|
|
|
|
|
|
|
|
self._delete_iter = None |
|
|
|
self._delete_iter = None |
|
|
|
self._clear_reply() |
|
|
|
self._clear_reply() |
|
|
|
self._clear_repost() |
|
|
|
self._clear_repost() |
|
|
@ -753,35 +753,35 @@ 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): |
|
|
|
def _message_selected(self, view, user_data=None): |
|
|
|
"""Callback when a row in the list is selected. Mostly, we'll check |
|
|
|
"""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" |
|
|
|
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.""" |
|
|
|
cannot do.""" |
|
|
|
|
|
|
|
|
|
|
|
(model, iter) = view.get_selection().get_selected() |
|
|
|
(model, iter) = view.get_selection().get_selected() |
|
|
|
data = model.get_value(iter, 0) |
|
|
|
data = model.get_value(iter, 0) |
|
|
|
|
|
|
|
|
|
|
|
self._delete_action.set_property('sensitive', |
|
|
|
self._delete_action.set_property('sensitive', |
|
|
|
self._connection.can_delete(data)) |
|
|
|
self._connection.can_delete(data)) |
|
|
|
self._reply_action.set_property('sensitive', |
|
|
|
self._reply_action.set_property('sensitive', |
|
|
|
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)) |
|
|
|
|
|
|
|
|
|
|
|
return 0 |
|
|
|
return 0 |
|
|
|
|
|
|
|
|
|
|
|
def _clear_posts(self, widget, user_data=None): |
|
|
|
def _clear_posts(self, widget, user_data=None): |
|
|
|
"""Clear the list of posts from the grid.""" |
|
|
|
"""Clear the list of posts from the grid.""" |
|
|
|
self._grid.get_model().clear() |
|
|
|
self._grid.get_model().clear() |
|
|
|
return |
|
|
|
return |
|
|
|
|
|
|
|
|
|
|
|
def _delete_message(self, widget, user_data=None): |
|
|
|
def _delete_message(self, widget, user_data=None): |
|
|
|
"""Delete a message.""" |
|
|
|
"""Delete a message.""" |
|
|
|
(model, iter) = self._grid.get_selection().get_selected() |
|
|
|
(model, iter) = self._grid.get_selection().get_selected() |
|
|
|
message = model.get_value(iter, 0) |
|
|
|
message = model.get_value(iter, 0) |
|
|
|
|
|
|
|
|
|
|
|
self._update_statusbar('Deleting message...') |
|
|
|
self._update_statusbar('Deleting message...') |
|
|
|
self._delete_iter = iter |
|
|
|
self._delete_iter = iter |
|
|
|
_log.debug('Deleting messing %d', message.id) |
|
|
|
_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_label.set_text('Replying to %s' % (message.username)) |
|
|
|
self._reply_message_id = message |
|
|
|
self._reply_message_id = message |
|
|
|
self._update_text.grab_focus() |
|
|
|
self._update_text.grab_focus() |
|
|
|
|
|
|
|
|
|
|
|
return |
|
|
|
return |
|
|
|
|
|
|
|
|
|
|
|
# ------------------------------------------------------------ |
|
|
|
# ------------------------------------------------------------ |
|
|
|
# Network related functions |
|
|
|
# Network related functions |
|
|
|
# ------------------------------------------------------------ |
|
|
|
# ------------------------------------------------------------ |
|
|
|
|
|
|
|
|
|
|
|
### Results from the "messages" request |
|
|
|
### Results from the "messages" request |
|
|
|
def _post_get_messages(self, widget, results): |
|
|
|
def _post_get_messages(self, widget, results): |
|
|
|
"""Function called after the data from the messages list is |
|
|
|
"""Function called after the data from the messages list is |
|
|
@ -879,7 +879,7 @@ class Interface(object): |
|
|
|
_log.debug('Update error') |
|
|
|
_log.debug('Update error') |
|
|
|
_log.debug(str(exception)) |
|
|
|
_log.debug(str(exception)) |
|
|
|
return |
|
|
|
return |
|
|
|
|
|
|
|
|
|
|
|
### Results for the delete message call |
|
|
|
### Results for the delete message call |
|
|
|
def _post_delete_message(self, widget, data): |
|
|
|
def _post_delete_message(self, widget, data): |
|
|
|
"""Called when the message is deleted successfully.""" |
|
|
|
"""Called when the message is deleted successfully.""" |
|
|
@ -889,7 +889,7 @@ class Interface(object): |
|
|
|
self._delete_iter = None |
|
|
|
self._delete_iter = None |
|
|
|
self._update_statusbar('Message deleted.') |
|
|
|
self._update_statusbar('Message deleted.') |
|
|
|
return |
|
|
|
return |
|
|
|
|
|
|
|
|
|
|
|
def _exception_delete_message(self, widget, exception): |
|
|
|
def _exception_delete_message(self, widget, exception): |
|
|
|
"""Called when the message cannot be deleted.""" |
|
|
|
"""Called when the message cannot be deleted.""" |
|
|
|
_log.debug('Delete error') |
|
|
|
_log.debug('Delete error') |
|
|
@ -930,9 +930,9 @@ class Interface(object): |
|
|
|
self._delete_iter = None |
|
|
|
self._delete_iter = None |
|
|
|
self._reply_message_id = None |
|
|
|
self._reply_message_id = None |
|
|
|
self._repost_message_id = None |
|
|
|
self._repost_message_id = None |
|
|
|
|
|
|
|
|
|
|
|
return |
|
|
|
return |
|
|
|
|
|
|
|
|
|
|
|
def __call__(self): |
|
|
|
def __call__(self): |
|
|
|
"""Call function; displays the interface. This method should appear on |
|
|
|
"""Call function; displays the interface. This method should appear on |
|
|
|
every interface.""" |
|
|
|
every interface.""" |
|
|
|