From b5d73e8fd2584e51954ba5d722b3907461c5dee9 Mon Sep 17 00:00:00 2001 From: Gonzalo Odiard Date: Wed, 02 May 2012 10:53:17 +0000 Subject: Use FontComboBox to show font previews - Sans selected by default fix SL #2759 'Times New Roman' was selected by default in AbiWord but the font is not available, then the information in the doc and the font combo was out of sync. Signed-off-by: Gonzalo Odiard --- (limited to 'toolbar.py') diff --git a/toolbar.py b/toolbar.py index 9a924d3..4af47ff 100644 --- a/toolbar.py +++ b/toolbar.py @@ -37,8 +37,8 @@ from sugar.activity.widgets import UndoButton from sugar.activity.widgets import RedoButton from widgets import AbiButton -from widgets import FontCombo from widgets import FontSizeCombo +from fontcombobox import FontComboBox logger = logging.getLogger('write-activity') @@ -402,8 +402,13 @@ class TextToolbar(gtk.Toolbar): def __init__(self, abiword_canvas): gtk.Toolbar.__init__(self) - font_name = ToolComboBox(FontCombo(abiword_canvas)) - self.insert(font_name, -1) + self.font_name_combo = FontComboBox() + self.font_name_combo.set_font_name('Sans') + self._fonts_changed_id = self.font_name_combo.connect('changed', + self._font_changed_cb, abiword_canvas) + self._abi_handler = abiword_canvas.connect('font-family', + self._font_family_cb) + self.insert(ToolComboBox(self.font_name_combo), -1) font_size = ToolComboBox(FontSizeCombo(abiword_canvas)) self.insert(font_size, -1) @@ -449,6 +454,18 @@ class TextToolbar(gtk.Toolbar): self.show_all() + def _font_changed_cb(self, combobox, abi): + logger.debug('Setting font: %s', combobox.get_font_name()) + try: + abi.handler_block(self._abi_handler) + abi.set_font_name(combobox.get_font_name()) + finally: + abi.handler_unblock(self._abi_handler) + + def _font_family_cb(self, abi, font_family): + logging.debug('Abiword font changed to %s', font_family) + self.font_name_combo.set_font_name(font_family) + def _setToggleButtonState(self, button, b, id): button.handler_block(id) button.set_active(b) -- cgit v0.9.1