Browse Source

Merge commit 'imrehg/features'

master
Julio Biason 16 years ago
parent
commit
5895f733b3
  1. 47
      mitterlib/ui/ui_pygtk.py

47
mitterlib/ui/ui_pygtk.py

@ -70,9 +70,9 @@ class _IdleObject(gobject.GObject):
""" """
def __init__(self): def __init__(self):
gobject.GObject.__init__(self) gobject.GObject.__init__(self)
def emit(self, *args): 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): class _WorkerThread(threading.Thread, _IdleObject):
@ -86,17 +86,17 @@ class _WorkerThread(threading.Thread, _IdleObject):
(gobject.TYPE_PYOBJECT,)), # list/networkdata (gobject.TYPE_PYOBJECT,)), # list/networkdata
"exception": ( "exception": (
gobject.SIGNAL_RUN_LAST, gobject.SIGNAL_RUN_LAST,
gobject.TYPE_NONE, gobject.TYPE_NONE,
(gobject.TYPE_PYOBJECT,)) # The exception (gobject.TYPE_PYOBJECT,)) # The exception
} }
def __init__(self, function, *args, **kwargs): def __init__(self, function, *args, **kwargs):
threading.Thread.__init__(self) threading.Thread.__init__(self)
_IdleObject.__init__(self) _IdleObject.__init__(self)
self._function = function self._function = function
self._args = args self._args = args
self._kwargs = kwargs self._kwargs = kwargs
def run(self): def run(self):
# call the function # call the function
_log.debug('Thread %s calling %s', self.name, str(self._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 # not actually a widget. It's the object that emitted the signal, in
# this case, the _WorkerThread object. # 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, _log.debug('Thread %s completed, %d threads in the queue', thread_id,
len(self._thread_pool)) len(self._thread_pool))
@ -378,7 +378,7 @@ 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)
self._update_action = gtk.Action('Update', '_Update', self._update_action = gtk.Action('Update', '_Update',
'Update your status', gtk.STOCK_ADD) 'Update your status', gtk.STOCK_ADD)
self._update_action.set_property('sensitive', False) self._update_action.set_property('sensitive', False)
self._update_action.connect('activate', self._update_status) self._update_action.connect('activate', self._update_status)
@ -484,6 +484,23 @@ class Interface(object):
update_area = gtk.VBox(True, 0) update_area = gtk.VBox(True, 0)
update_area.pack_start(update_box) 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 return update_area
def _create_statusbar(self): def _create_statusbar(self):
@ -601,7 +618,6 @@ class Interface(object):
# ------------------------------------------------------------ # ------------------------------------------------------------
# Widget callback functions # Widget callback functions
# ------------------------------------------------------------ # ------------------------------------------------------------
def _count_chars(self, text_buffer): def _count_chars(self, text_buffer):
"""Count the number of chars in the edit field and update the """Count the number of chars in the edit field and update the
label that shows the available space.""" label that shows the available space."""
@ -775,7 +791,6 @@ class Interface(object):
# ------------------------------------------------------------ # ------------------------------------------------------------
# Required functions for all interfaces # Required functions for all interfaces
# ------------------------------------------------------------ # ------------------------------------------------------------
def __init__(self, connection, options): def __init__(self, connection, options):
"""Start the interface. `connection` is the :class:`Networks` object """Start the interface. `connection` is the :class:`Networks` object
with all the available networks. `options` is the :class:`ConfigOpt` with all the available networks. `options` is the :class:`ConfigOpt`
@ -813,7 +828,7 @@ class Interface(object):
self._threads = _ThreadManager() self._threads = _ThreadManager()
# queue the first fetch # 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._exception_get_messages,
self._connection.messages) self._connection.messages)
@ -887,4 +902,12 @@ class Interface(object):
default='blue', default='blue',
conflict_group='interface', conflict_group='interface',
is_cmd_option=False) 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)

Loading…
Cancel
Save