diff options
author | Gonzalo Odiard <godiard@gmail.com> | 2013-06-11 15:29:06 (GMT) |
---|---|---|
committer | Gonzalo Odiard <godiard@gmail.com> | 2013-06-11 15:29:06 (GMT) |
commit | d61a5dc2edb705b0baa5f64a9bcf0c5a9d9a6cbd (patch) | |
tree | 9bfa1bc997273aea9fa34c714fb2409096efb0c7 | |
parent | 1dd1003a7eeb03f36dbe548bd964fcacde4a8997 (diff) |
Improve controls on FontSize.set_font_size()
The method is not used in Paint yet, but used in other activities
like Write.
Signed-off-by: Gonzalo Odiard <gonzalo@laptop.org>
-rw-r--r-- | fontcombobox.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/fontcombobox.py b/fontcombobox.py index 3ce1ef9..0ae4d0f 100644 --- a/fontcombobox.py +++ b/fontcombobox.py @@ -283,7 +283,24 @@ class FontSize(Gtk.ToolItem): self.emit('changed') def set_font_size(self, size): + if size not in self._font_sizes: + # assure the font assigned is in the range + # if not, assign one close. + for font_size in self._font_sizes: + if font_size > size: + size = font_size + break + if size > self._font_sizes[-1]: + size = self._font_sizes[-1] + self._font_size = size + self._size_label.set_text(str(self._font_size)) + + # update the buttons states + i = self._font_sizes.index(self._font_size) + self._size_down.set_sensitive(i != 0) + self._size_up.set_sensitive(i < len(self._font_sizes) - 1) + self.emit('changed') def get_font_size(self): return self._font_size |