From 5fb6146a3d22da2b006886f7afb94f3475dc686c Mon Sep 17 00:00:00 2001 From: Zsolt Foldvari Date: Fri, 11 Apr 2008 10:28:19 +0000 Subject: [PATCH] Custom font selector dialog as a workaround for conflicting font style settings. svn: r10547 --- src/Editors/_StyledTextBuffer.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/Editors/_StyledTextBuffer.py b/src/Editors/_StyledTextBuffer.py index 02d557402..8ce21c2b3 100644 --- a/src/Editors/_StyledTextBuffer.py +++ b/src/Editors/_StyledTextBuffer.py @@ -552,7 +552,7 @@ class StyledTextBuffer(gtk.TextBuffer): value = self._color_to_hex(color) color_selection.destroy() elif format == 'font': - font_selection = gtk.FontSelectionDialog(_("Select font")) + font_selection = CustomFontSelectionDialog(_("Select font")) if self.font: font_selection.fontsel.set_font_name(self.font) response = font_selection.run() @@ -652,3 +652,27 @@ class StyledTextBuffer(gtk.TextBuffer): return match return None + +#------------------------------------------------------------------------- +# +# CustomFontSelectionDialog class +# +#------------------------------------------------------------------------- +class CustomFontSelectionDialog(gtk.FontSelectionDialog): + """A FontSelectionDialog without the Style treeview. + + This should be only a workaround until a real custom font selector + is created, because this solution is gtk implementation dependent. + + """ + def __init__(self, title): + gtk.FontSelectionDialog.__init__(self, title) + + # hide the Style label and treeview + for widget in self.fontsel.get_children(): + if isinstance(widget, gtk.Table): + table = widget + + for child in table.get_children(): + if table.child_get_property(child, 'left-attach') == 1: + child.hide() \ No newline at end of file