diff options
author | Gonzalo Odiard <godiard@gmail.com> | 2013-06-10 21:36:45 (GMT) |
---|---|---|
committer | Gonzalo Odiard <godiard@gmail.com> | 2013-06-10 21:41:49 (GMT) |
commit | 1a3ca0bee151df898ef5e712d45f227a1e697d82 (patch) | |
tree | 805d5efca6489a7537553c4bb9a52b3ee2f931bf | |
parent | 5189367dc739e7fa6924ecb50d3b409041267799 (diff) |
Update toolbar to use the font size widget
Signed-off-by: Gonzalo Odiard <gonzalo@laptop.org>
-rw-r--r-- | icons/resize+.svg | 41 | ||||
-rw-r--r-- | icons/resize-.svg | 43 | ||||
-rw-r--r-- | toolbox.py | 24 |
3 files changed, 93 insertions, 15 deletions
diff --git a/icons/resize+.svg b/icons/resize+.svg new file mode 100644 index 0000000..0fae3c3 --- /dev/null +++ b/icons/resize+.svg @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + version="1.1" + width="55" + height="54.695999" + viewBox="0 0 55 54.696" + id="svg2" + xml:space="preserve"><defs + id="defs21"> + + + + + </defs><g + transform="translate(-0.4354,0)" + id="g7"> + <g + id="g9"> + <path + d="m 25.263,12.435 h 24.656 v 3.562 H 39.575 V 41.59 H 35.606 V 15.996 H 25.263 v -3.561 z" + id="path11" + style="fill:#ffffff" /> + </g> + </g><g + transform="translate(-8.4356,0)" + id="g13"> + <g + id="g15"> + <path + d="m 13.953,24.435 h 16.656 v 3.562 H 24.265 V 41.59 H 20.296 V 27.997 h -6.344 v -3.562 z" + id="path17" + style="fill:#ffffff" /> + </g> + </g><path + d="m 25.5774,23.677763 6,-6.000001 -4,0" + id="path3618" + style="fill:none;stroke:#ffffff;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></svg>
\ No newline at end of file diff --git a/icons/resize-.svg b/icons/resize-.svg new file mode 100644 index 0000000..e3b719e --- /dev/null +++ b/icons/resize-.svg @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + version="1.1" + width="55" + height="54.695999" + viewBox="0 0 55 54.696" + id="svg2" + xml:space="preserve"><defs + id="defs21"> + + + + + </defs><g + transform="translate(3.5644,0)" + id="g2821"><g + transform="matrix(-1,0,0,1,51.871,0)" + id="g7"> + <g + id="g9"> + <path + d="m 25.263,12.435 h 24.656 v 3.562 H 39.575 V 41.59 H 35.606 V 15.996 H 25.263 v -3.561 z" + id="path11" + style="fill:#ffffff" /> + </g> + </g><g + transform="matrix(-1,0,0,1,59.8712,0)" + id="g13"> + <g + id="g15"> + <path + d="m 13.953,24.435 h 16.656 v 3.562 H 24.265 V 41.59 H 20.296 V 27.997 h -6.344 v -3.562 z" + id="path17" + style="fill:#ffffff" /> + </g> + </g><path + d="m 19.8582,17.677762 6,6.000001 -4,0" + id="path3618" + style="fill:none;stroke:#ffffff;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g></svg>
\ No newline at end of file @@ -88,6 +88,7 @@ from sugar3.graphics.toolbarbox import ToolbarButton, ToolbarBox from sugar3.activity.widgets import StopButton from fontcombobox import FontComboBox +from fontcombobox import FontSize def add_menu(icon_name, tooltip, tool_name, button, activate_cb): @@ -592,26 +593,19 @@ class TextToolbar(Gtk.Toolbar): separator.set_draw(True) self.insert(separator, -1) - fd = activity.area.get_font_description() - - self._font_size_combo = Gtk.ComboBoxText() - self._font_sizes = ['8', '10', '12', '14', '16', '20', - '22', '24', '26', '28', '36', '48', '72'] - self._font_size_changed_id = self._font_size_combo.connect('changed', + self._font_size = FontSize() + self.insert(self._font_size, -1) + self._font_size_changed_id = self._font_size.connect('changed', self.__font_size_changed_cb) - for i, s in enumerate(self._font_sizes): - self._font_size_combo.append_text(s) - if int(s) == (fd.get_size() / Pango.SCALE): - self._font_size_combo.set_active(i) - - tool_item = ToolComboBox(self._font_size_combo) - self.insert(tool_item, -1) self._font_combo = FontComboBox() self._fonts_changed_id = self._font_combo.connect('changed', self.__font_changed_cb) + + fd = activity.area.get_font_description() font_name = fd.get_family() self._font_combo.set_font_name(font_name) + self._font_size.set_font_size(int(fd.get_size() / Pango.SCALE)) tool_item = ToolComboBox(self._font_combo) self.insert(tool_item, -1) self.show_all() @@ -632,9 +626,9 @@ class TextToolbar(Gtk.Toolbar): fd.set_style(Pango.Style.NORMAL) self._activity.area.set_font_description(fd) - def __font_size_changed_cb(self, combo): + def __font_size_changed_cb(self, widget): fd = self._activity.area.get_font_description() - value = self.get_active_text(combo) + value = widget.get_font_size() fd.set_size(int(value) * Pango.SCALE) self._activity.area.set_font_description(fd) |