From 7641842202130b064d7f82ac3ff5497eecfdc5bd Mon Sep 17 00:00:00 2001 From: Gary Martin Date: Tue, 08 Sep 2009 14:24:15 +0000 Subject: Removed redundant StyleCombo code from widgets.py --- diff --git a/widgets.py b/widgets.py index 67d2e46..c8c26fc 100644 --- a/widgets.py +++ b/widgets.py @@ -122,79 +122,6 @@ class FontSizeCombo(ComboBox): self.handler_unblock(self._changed_id) break; -class StyleCombo(ComboBox): - def __init__(self, abi): - ComboBox.__init__(self) - - self._abi_handler = abi.connect('style-name', self._style_cb) - - self._styles = [ ['Heading 1', _('Heading 1')], - ['Heading 2', _('Heading 2')], - ['Heading 3', _('Heading 3')], - ['Heading 4', _('Heading 4')], - ['Bullet List', _('Bullet List')], - ['Dashed List', _('Dashed List')], - ['Numbered List', _('Numbered List')], - ['Lower Case List', _('Lower Case List')], - ['Upper Case List', _('Upper Case List')], - ['Block Text', _('Block Text')], - ['Normal', _('Normal')], - ['Plain Text', _('Plain Text')] ] - - self._has_custom_styles = False - self._style_changed_id = self.connect('changed', self._style_changed_cb, - abi) - - for i, s in enumerate(self._styles): - self.append_item(i, s[1], None) - if s[0] == 'Normal': - self.set_active(i) - - def _style_changed_cb(self, combobox, abi): - if self.get_active() != -1: - logger.debug('Set style: %s', self._styles[self.get_active()][0]) - try: - abi.handler_block(self._abi_handler) - abi.set_style(self._styles[self.get_active()][0]) - finally: - abi.handler_unblock(self._abi_handler) - - def _style_cb(self, abi, style_name): - if style_name is None or style_name == 'None': - style_name = 'Normal' - - style_index = -1 - for i, s in enumerate(self._styles): - if s[0] == style_name: - style_index = i - break; - - # if we don't know this style yet, then add it (temporary) to the list - if style_index == -1: - logger.debug('Style not found in style list: %s', style_name) - - if not self._has_custom_styles: - # add a separator to seperate the non-available styles from - # the available ones - self._styles.append(['','']) # ugly - self.append_separator() - self._has_custom_styles = True - - # add the new style - self._styles.append([style_name, style_name]) - self.append_item(0, style_name, None) - - # see how many styles we have now, so we can select the last one - model = self.get_model() - num_children = model.iter_n_children(None) - logger.debug('Number of styles in the list: %d', num_children) - style_index = num_children-1 - - if style_index > -1: - self.handler_block(self._style_changed_id) - self.set_active(style_index) - self.handler_unblock(self._style_changed_id) - class AbiButton(RadioToolButton): def __init__(self, abi, abi_signal, do_abi_cb, on_abi_cb=None, **kwargs): RadioToolButton.__init__(self, **kwargs) -- cgit v0.9.1