Package list sugar-read-activity / 3794bfc
Add buttons to "zoom to fit" and "actual size" - SL #3752 Signed-off-by: Gonzalo Odiard <gonzalo@laptop.org> Gonzalo Odiard 9 years ago
2 changed file(s) with 58 addition(s) and 18 deletion(s). Raw diff Collapse all Expand all
0 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
1 <!-- Created with Inkscape (http://www.inkscape.org/) -->
2
3 <svg
4 xmlns:dc="http://purl.org/dc/elements/1.1/"
5 xmlns:cc="http://creativecommons.org/ns#"
6 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
7 xmlns:svg="http://www.w3.org/2000/svg"
8 xmlns="http://www.w3.org/2000/svg"
9 version="1.1"
10 width="55"
11 height="54.695999"
12 viewBox="0 0 55 54.696"
13 id="svg2"
14 xml:space="preserve"><metadata
15 id="metadata19"><rdf:RDF><cc:Work
16 rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
17 rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
18 id="defs17">
19
20
21
22
23
24
25 </defs><path
26 d="m 9.875,23.546 c 0,7.569 6.131,13.704 13.702,13.704 7.562,0 13.694,-6.135 13.694,-13.704 0,-7.564 -6.132,-13.698 -13.694,-13.698 -7.571,0 -13.702,6.134 -13.702,13.698 z"
27 id="path7"
28 style="fill:#808284;stroke:#ffffff;stroke-width:3.5" /><line
29 x1="33.265999"
30 x2="45.047001"
31 y1="33.262001"
32 y2="45.044998"
33 id="line9"
34 style="fill:none;stroke:#ffffff;stroke-width:3.5" /><path
35 d="m 18.410155,20.165477 -0.04518,6.767046"
36 id="path3777"
37 style="fill:#ffffff;fill-opacity:1;stroke:#ffffff;stroke-width:2.26210141;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /><path
38 d="m 28.742616,20.165477 -0.04518,6.767046"
39 id="path3777-9"
40 style="fill:#ffffff;fill-opacity:1;stroke:#ffffff;stroke-width:2.26210141;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /><path
41 d="m 17.772993,23.529794 11.600013,0 -0.153643,0.03841"
42 id="path3797"
43 style="fill:#ffffff;fill-opacity:1;stroke:#ffffff;stroke-width:2.61999989;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></svg>
2424 from sugar3.graphics.menuitem import MenuItem
2525 from sugar3.graphics import iconentry
2626 from sugar3.activity.widgets import EditToolbar as BaseEditToolbar
27 from sugarmenuitem import SugarMenuItem
2827
2928
3029 class EditToolbar(BaseEditToolbar):
184183 self.insert(self._zoom_in, -1)
185184 self._zoom_in.show()
186185
187 self._zoom_to_width = ToolButton('zoom-best-fit')
186 self._zoom_to_width = ToolButton('zoom-to-width')
188187 self._zoom_to_width.set_tooltip(_('Zoom to width'))
189188 self._zoom_to_width.connect('clicked', self._zoom_to_width_cb)
190189 self.insert(self._zoom_to_width, -1)
191190 self._zoom_to_width.show()
192191
193 vbox_menu = Gtk.VBox()
194 fit_menu = SugarMenuItem(text_label=_('Zoom to fit'))
195 fit_menu.connect('clicked', self._zoom_to_fit_menu_item_activate_cb)
196 vbox_menu.add(fit_menu)
197 actual_size_menu = SugarMenuItem(text_label=_('Actual size'))
198 actual_size_menu.connect('clicked',
199 self._actual_size_menu_item_activate_cb)
200 vbox_menu.add(actual_size_menu)
201 vbox_menu.show_all()
202
203 palette = self._zoom_to_width.get_palette()
204 palette.set_content(vbox_menu)
205 # HACK
206 palette._content.set_border_width(1)
192 self._zoom_to_fit = ToolButton('zoom-best-fit')
193 self._zoom_to_fit.set_tooltip(_('Zoom to fit'))
194 self._zoom_to_fit.connect('clicked', self._zoom_to_fit_cb)
195 self.insert(self._zoom_to_fit, -1)
196 self._zoom_to_fit.show()
197
198 self._zoom_to_original = ToolButton('zoom-original')
199 self._zoom_to_original.set_tooltip(_('Actual size'))
200 self._zoom_to_original.connect('clicked', self._actual_size_cb)
201 self.insert(self._zoom_to_original, -1)
202 self._zoom_to_original.show()
207203
208204 tool_item = Gtk.ToolItem()
209205 self.insert(tool_item, -1)
284280 self._zoom_out.props.sensitive = self._view.can_zoom_out()
285281 self._zoom_to_width.props.sensitive = self._view.can_zoom_to_width()
286282
287 def _zoom_to_fit_menu_item_activate_cb(self, menu_item):
283 def _zoom_to_fit_cb(self, menu_item):
288284 self._view.zoom_to_best_fit()
289285 self._update_zoom_buttons()
290286
291 def _actual_size_menu_item_activate_cb(self, menu_item):
287 def _actual_size_cb(self, menu_item):
292288 self._view.zoom_to_actual_size()
293289 self._update_zoom_buttons()
294290