From 5d9709ad66060f1900c6cd7982a70e4a07a15bd2 Mon Sep 17 00:00:00 2001 From: Gergely Imreh Date: Tue, 19 May 2009 10:49:15 +0800 Subject: [PATCH 1/2] ui_pygtk: cleaning up formatting errors reported by pyflakes --- mitterlib/ui/ui_pygtk.py | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/mitterlib/ui/ui_pygtk.py b/mitterlib/ui/ui_pygtk.py index cc88261..949a25d 100644 --- a/mitterlib/ui/ui_pygtk.py +++ b/mitterlib/ui/ui_pygtk.py @@ -70,9 +70,9 @@ class _IdleObject(gobject.GObject): """ def __init__(self): gobject.GObject.__init__(self) - + def emit(self, *args): - gobject.idle_add(gobject.GObject.emit,self,*args) + gobject.idle_add(gobject.GObject.emit, self, *args) class _WorkerThread(threading.Thread, _IdleObject): @@ -86,17 +86,17 @@ class _WorkerThread(threading.Thread, _IdleObject): (gobject.TYPE_PYOBJECT,)), # list/networkdata "exception": ( gobject.SIGNAL_RUN_LAST, - gobject.TYPE_NONE, + gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT,)) # The exception } - + def __init__(self, function, *args, **kwargs): threading.Thread.__init__(self) _IdleObject.__init__(self) self._function = function self._args = args self._kwargs = kwargs - + def run(self): # call the function _log.debug('Thread %s calling %s', self.name, str(self._function)) @@ -137,8 +137,8 @@ class _ThreadManager(object): # not actually a widget. It's the object that emitted the signal, in # this case, the _WorkerThread object. - thread_id = widget.name - + thread_id = widget.name + _log.debug('Thread %s completed, %d threads in the queue', thread_id, len(self._thread_pool)) @@ -378,7 +378,7 @@ class Interface(object): 'Settings', gtk.STOCK_PREFERENCES) #settings_action.connect('activate', self.show_settings) - self._update_action = gtk.Action('Update', '_Update', + self._update_action = gtk.Action('Update', '_Update', 'Update your status', gtk.STOCK_ADD) self._update_action.set_property('sensitive', False) self._update_action.connect('activate', self._update_status) @@ -601,7 +601,6 @@ class Interface(object): # ------------------------------------------------------------ # Widget callback functions # ------------------------------------------------------------ - def _count_chars(self, text_buffer): """Count the number of chars in the edit field and update the label that shows the available space.""" @@ -775,7 +774,6 @@ class Interface(object): # ------------------------------------------------------------ # Required functions for all interfaces # ------------------------------------------------------------ - def __init__(self, connection, options): """Start the interface. `connection` is the :class:`Networks` object with all the available networks. `options` is the :class:`ConfigOpt` @@ -813,7 +811,7 @@ class Interface(object): self._threads = _ThreadManager() # queue the first fetch - self._threads.add_work(self._post_get_messages, + self._threads.add_work(self._post_get_messages, self._exception_get_messages, self._connection.messages) @@ -887,4 +885,3 @@ class Interface(object): default='blue', conflict_group='interface', is_cmd_option=False) - From 78351349a300f4bab73e5ca0067be8639973675b Mon Sep 17 00:00:00 2001 From: Gergely Imreh Date: Wed, 20 May 2009 23:12:42 +0800 Subject: [PATCH 2/2] ui_pygtk: initial spell checking support for the update box --- mitterlib/ui/ui_pygtk.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/mitterlib/ui/ui_pygtk.py b/mitterlib/ui/ui_pygtk.py index 949a25d..2f0fce3 100644 --- a/mitterlib/ui/ui_pygtk.py +++ b/mitterlib/ui/ui_pygtk.py @@ -484,6 +484,23 @@ class Interface(object): update_area = gtk.VBox(True, 0) update_area.pack_start(update_box) + """ Spell checking the update box """ + spell_check_enabled = self._options[self.NAMESPACE]['spell_check'] + if spell_check_enabled: + try: + import gtkspell + import locale + self.spell_check_support = True + language = locale.getlocale()[0] + self.spell_check = gtkspell.Spell(self._update_text, language) + _log.debug('Spell checking turned on with language: %s' \ + % (language)) + except: + self._options[self.NAMESPACE]['spell_check'] = False + self.spell_check_support = False + _log.debug('Error initializing spell checking: ' \ + 'spell checking disabled') + return update_area def _create_statusbar(self): @@ -885,3 +902,12 @@ class Interface(object): default='blue', conflict_group='interface', is_cmd_option=False) + options.add_option( + group=self.NAMESPACE, + option='spell_check', + help='Spell checking update text', + type='boolean', + metavar='SPELL', + default=False, + conflict_group='interface', + is_cmd_option=False)