|
|
|
@ -234,10 +234,6 @@ class Interface(object):
|
|
|
|
|
if self._images['main']: |
|
|
|
|
main_window.set_icon(self._images['main']) |
|
|
|
|
|
|
|
|
|
main_window.connect('destroy', self._quit_app) |
|
|
|
|
main_window.connect('delete-event', self._quit_app) |
|
|
|
|
main_window.connect('size-request', self._grid_resize) |
|
|
|
|
|
|
|
|
|
(menu, toolbar, accelerators) = self._create_menu_and_toolbar() |
|
|
|
|
update_field = self._create_update_box() |
|
|
|
|
self._statusbar = self._create_statusbar() |
|
|
|
@ -266,6 +262,16 @@ class Interface(object):
|
|
|
|
|
|
|
|
|
|
self._message_count_updated() |
|
|
|
|
|
|
|
|
|
# now that all elements are created, connect the signals |
|
|
|
|
main_window.connect('destroy', self._quit_app) |
|
|
|
|
main_window.connect('delete-event', self._quit_app) |
|
|
|
|
main_window.connect('size-request', self._grid_resize) |
|
|
|
|
|
|
|
|
|
self._update_text.get_buffer().connect('changed', self._count_chars) |
|
|
|
|
self._update_text.connect('focus-out-event', |
|
|
|
|
self._remove_count_status) |
|
|
|
|
self._update_text.connect('focus-in-event', self._on_textarea_focus) |
|
|
|
|
|
|
|
|
|
return main_window |
|
|
|
|
|
|
|
|
|
def _create_grid(self, counter): |
|
|
|
@ -476,7 +482,6 @@ class Interface(object):
|
|
|
|
|
self._update_text = gtk.TextView() |
|
|
|
|
self._update_text.set_property('wrap-mode', gtk.WRAP_WORD) |
|
|
|
|
text_buffer = self._update_text.get_buffer() |
|
|
|
|
text_buffer.connect('changed', self._count_chars) |
|
|
|
|
|
|
|
|
|
self._update_button = gtk.Button(label='Send') |
|
|
|
|
self._update_button.connect('clicked', self._update_status) |
|
|
|
@ -491,11 +496,6 @@ class Interface(object):
|
|
|
|
|
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) |
|
|
|
@ -504,11 +504,7 @@ class Interface(object):
|
|
|
|
|
update_box.pack_start(self._cancel_button, expand=False, fill=False, |
|
|
|
|
padding=0) |
|
|
|
|
|
|
|
|
|
update_area = gtk.VBox(True, 0) |
|
|
|
|
update_area.pack_start(info_box) |
|
|
|
|
update_area.pack_start(update_box) |
|
|
|
|
|
|
|
|
|
""" Spell checking the update box """ |
|
|
|
|
# Spell checking the update box |
|
|
|
|
spell_check_enabled = self._options[self.NAMESPACE]['spell_check'] |
|
|
|
|
if spell_check_enabled: |
|
|
|
|
try: |
|
|
|
@ -525,7 +521,7 @@ class Interface(object):
|
|
|
|
|
_log.debug('Error initializing spell checking: ' \ |
|
|
|
|
'spell checking disabled') |
|
|
|
|
|
|
|
|
|
return update_area |
|
|
|
|
return update_box |
|
|
|
|
|
|
|
|
|
def _create_statusbar(self): |
|
|
|
|
"""Create the statusbar.""" |
|
|
|
@ -646,6 +642,7 @@ class Interface(object):
|
|
|
|
|
|
|
|
|
|
def _update_statusbar(self, message): |
|
|
|
|
"""Update the statusbar with the message.""" |
|
|
|
|
self._statusbar.pop(self._statusbar_context) |
|
|
|
|
self._statusbar.push(self._statusbar_context, message) |
|
|
|
|
return |
|
|
|
|
|
|
|
|
@ -782,7 +779,10 @@ class Interface(object):
|
|
|
|
|
count = len(text) |
|
|
|
|
|
|
|
|
|
# TODO: gettext to properly use "characters"/"character" |
|
|
|
|
self._count_label.set_text('%d characters' % count) |
|
|
|
|
text = '%d characters' % (count) |
|
|
|
|
|
|
|
|
|
#self._count_label.set_text(text) |
|
|
|
|
self._statusbar.push(self._remove_count_status(), text) |
|
|
|
|
self._update_sensitivity(not (count == 0)) |
|
|
|
|
|
|
|
|
|
return True |
|
|
|
@ -796,6 +796,8 @@ class Interface(object):
|
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
_log.debug('Status: %s', status) |
|
|
|
|
self._remove_count_status() |
|
|
|
|
|
|
|
|
|
self._update_statusbar('Sending update...') |
|
|
|
|
self._update_sensitivity(False) |
|
|
|
|
self._threads.add_work(self._post_update_status, |
|
|
|
@ -811,7 +813,7 @@ class Interface(object):
|
|
|
|
|
|
|
|
|
|
self._delete_iter = None |
|
|
|
|
self._clear_reply() |
|
|
|
|
|
|
|
|
|
self._remove_count_status() |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
def _quit_app(self, widget=None, user_data=None): |
|
|
|
@ -1105,6 +1107,20 @@ class Interface(object):
|
|
|
|
|
self._main_tabs.set_current_page(user_data) |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
def _remove_count_status(self, widget=None, user_data=None): |
|
|
|
|
"""Find the context with the char count in the statusbar and remove |
|
|
|
|
it (pop). Returns the context of the count, in case some other |
|
|
|
|
function wants to add another message.""" |
|
|
|
|
count_context = self._statusbar.get_context_id('counter') |
|
|
|
|
self._statusbar.pop(count_context) |
|
|
|
|
return count_context |
|
|
|
|
|
|
|
|
|
def _on_textarea_focus(self, widget, user_data=None): |
|
|
|
|
"""Called when the text area gets the focus. Just to add the counter |
|
|
|
|
again.""" |
|
|
|
|
self._count_chars(self._update_text.get_buffer()) |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
# ------------------------------------------------------------ |
|
|
|
|
# Network related functions |
|
|
|
|
# ------------------------------------------------------------ |
|
|
|
|