|
|
|
@ -394,9 +394,8 @@ class Interface(object):
|
|
|
|
|
self._delete_action = gtk.Action('Delete', '_Delete', |
|
|
|
|
'Delete a post', gtk.STOCK_DELETE) |
|
|
|
|
self._delete_action.set_property('sensitive', False) |
|
|
|
|
# TODO: Reconnect |
|
|
|
|
#delete_action.connect('activate', self.delete_tweet) |
|
|
|
|
action_group.add_action_with_accel(self._delete_action, '<Delete>') |
|
|
|
|
self._delete_action.connect('activate', self._delete_message) |
|
|
|
|
action_group.add_action_with_accel(self._delete_action, 'Delete') |
|
|
|
|
# TODO: Check the accelerator |
|
|
|
|
|
|
|
|
|
self._reply_action = gtk.Action('Reply', '_Reply', |
|
|
|
@ -453,8 +452,8 @@ class Interface(object):
|
|
|
|
|
self._count_label.set_justify(gtk.JUSTIFY_LEFT) |
|
|
|
|
self._reply_label = gtk.Label() |
|
|
|
|
|
|
|
|
|
info_box.pack_start(self._count_label) |
|
|
|
|
info_box.pack_start(self._reply_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) |
|
|
|
|
|
|
|
|
@ -604,6 +603,28 @@ class Interface(object):
|
|
|
|
|
self._cancel_action.set_property('sensitive', enabled) |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
def _refresh(self, widget=None): |
|
|
|
|
"""Request a refresh. *widget* is the widget that called this |
|
|
|
|
function (we basically ignore it.)""" |
|
|
|
|
if self._refresh_id: |
|
|
|
|
# "De-queue" the next refresh |
|
|
|
|
_log.debug('Dequeuing next refresh') |
|
|
|
|
gobject.source_remove(self._refresh_id) |
|
|
|
|
self._refresh_id = None |
|
|
|
|
|
|
|
|
|
# do the refresh |
|
|
|
|
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) |
|
|
|
|
self._refresh_id = gobject.timeout_add( |
|
|
|
|
interval * 60 * 1000, |
|
|
|
|
self._refresh, None) |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
# ------------------------------------------------------------ |
|
|
|
|
# Widget callback functions |
|
|
|
|
# ------------------------------------------------------------ |
|
|
|
@ -614,7 +635,7 @@ class Interface(object):
|
|
|
|
|
count = len(text) |
|
|
|
|
|
|
|
|
|
# TODO: gettext to properly use "characters"/"character" |
|
|
|
|
self._count_label.set_text('%d characters available' % (140 - count)) |
|
|
|
|
self._count_label.set_text('%d characters' % count) |
|
|
|
|
#self._update_button.set_label('(%d)' % (140 - count)) |
|
|
|
|
self._update_sensitivity(not (count == 0)) |
|
|
|
|
|
|
|
|
@ -730,33 +751,34 @@ class Interface(object):
|
|
|
|
|
"""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) |
|
|
|
|
|
|
|
|
|
if not self._connection.can_delete(message): |
|
|
|
|
# Since we delete only one message, we don't need to worry about |
|
|
|
|
# multiple networks here. |
|
|
|
|
error_dialog = gtk.MessageDialog(parent=self._main_window, |
|
|
|
|
type=gtk.MESSAGE_ERROR, |
|
|
|
|
message_format='Message cannot be deleted', |
|
|
|
|
buttons=gtk.BUTTONS_OK) |
|
|
|
|
error_dialog.run() |
|
|
|
|
error_dialog.destroy() |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
_log.debug('Deleting messing %d', message.id) |
|
|
|
|
self._threads.add_work(self._post_delete_message, |
|
|
|
|
self._exception_delete_message, |
|
|
|
|
self._connection.delete_message, |
|
|
|
|
message) |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
# ------------------------------------------------------------ |
|
|
|
|
# Network related functions |
|
|
|
|
# ------------------------------------------------------------ |
|
|
|
|
|
|
|
|
|
def _refresh(self, widget=None): |
|
|
|
|
"""Request a refresh. *widget* is the widget that called this |
|
|
|
|
function (we basically ignore it.)""" |
|
|
|
|
if self._refresh_id: |
|
|
|
|
# "De-queue" the next refresh |
|
|
|
|
_log.debug('Dequeuing next refresh') |
|
|
|
|
gobject.source_remove(self._refresh_id) |
|
|
|
|
self._refresh_id = None |
|
|
|
|
|
|
|
|
|
# do the refresh |
|
|
|
|
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) |
|
|
|
|
self._refresh_id = gobject.timeout_add( |
|
|
|
|
interval * 60 * 1000, |
|
|
|
|
self._refresh, None) |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
### Results from the "messages" request |
|
|
|
|
def _post_get_messages(self, widget, results): |
|
|
|
|
"""Function called after the data from the messages list is |
|
|
|
@ -823,6 +845,18 @@ 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.""" |
|
|
|
|
_log.debug('Message deleted.') |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
def _exception_delete_message(self, widget, exception): |
|
|
|
|
"""Called when the message cannot be deleted.""" |
|
|
|
|
_log.debug('Delete error') |
|
|
|
|
_log.debug(str(exception)) |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
# ------------------------------------------------------------ |
|
|
|
|
# Required functions for all interfaces |
|
|
|
|