[Sugar-devel] [PATCH] move stop/reload button into the url entry
manuel quiñones
manuel.por.aca at gmail.com
Fri Aug 26 07:29:24 EDT 2011
2011/8/25 Simon Schampijer <simon at schampijer.de>:
> From: Simon Schampijer <simon at laptop.org>
>
> This patch does move the stop and reload button from the toolbar
> to the url entry similar to what Safari and Epiphany are doing.
> This has the nice side effect that we gain extra space for the
> url entry itself.
>
> Signed-off-by: Simon Schampijer <simon at laptop.org>
> ---
> icons/browse-dialog-cancel.svg | 17 +++++++++++++++++
> icons/browse-view-refresh.svg | 14 ++++++++++++++
> webtoolbar.py | 21 ++++++++++-----------
> 3 files changed, 41 insertions(+), 11 deletions(-)
> create mode 100644 icons/browse-dialog-cancel.svg
> create mode 100644 icons/browse-view-refresh.svg
>
> diff --git a/icons/browse-dialog-cancel.svg b/icons/browse-dialog-cancel.svg
> new file mode 100644
> index 0000000..46692e2
> --- /dev/null
> +++ b/icons/browse-dialog-cancel.svg
> @@ -0,0 +1,17 @@
> +<?xml version="1.0" encoding="UTF-8"?>
> +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [
> + <!ENTITY fill_color "#FFFFFF">
> + <!ENTITY stroke_color "#010101">
> +]>
> +<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="22.16" height="22.16" viewBox="0 0 22.16 22.16" id="svg2" xml:space="preserve">
> + <g transform="matrix(1.3,0,0,1.3,-3.2682282,-3.3351543)" id="browse-dialog-cancel" style="stroke-width:2.69230771;stroke-miterlimit:4;stroke-dasharray:none">
> + <path
> + d="M 14.798121,7.2131543 6.9900671,15.021208"
> + id="path2986"
> + style="fill:none;stroke:&stroke_color;;stroke-width:2.69230771;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
> + <path
> + d="M 6.9900671,7.2131543 14.798121,15.021208"
> + id="path3756"
> + style="fill:none;stroke:&stroke_color;;stroke-width:2.69230771;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
> + </g>
> +</svg>
> diff --git a/icons/browse-view-refresh.svg b/icons/browse-view-refresh.svg
> new file mode 100644
> index 0000000..0682978
> --- /dev/null
> +++ b/icons/browse-view-refresh.svg
> @@ -0,0 +1,14 @@
> +<?xml version="1.0" encoding="UTF-8"?>
> +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [
> + <!ENTITY fill_color "#FFFFFF">
> + <!ENTITY stroke_color "#010101">
> +]>
> +<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="22.16" height="22.16" viewBox="0 0 22.16 22.16" id="browse-view-refresh" xml:space="preserve">
> + <path
> + d="m 9.769744,17.559712 c -3.044496,-0.6084 -5.33832,-3.295344 -5.33832,-6.51768 0,-3.67224 2.97648,-6.649344 6.646848,-6.649344 3.672864,0 6.649344,2.977104 6.649344,6.649344 0,3.166176 -2.215824,5.816928 -5.18232,6.48648" id="path3220" style="fill:none;stroke:&stroke_color;;stroke-width:2.18400002;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
> + <polyline
> + points=" 22.936,31.578 25.5,37.994 18.746,39.439 "
> + id="polyline3222"
> + style="fill:none;stroke:&stroke_color;;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
> + transform="matrix(0.624,0,0,0.624,-6.142256,-6.148544)" />
> +</svg>
> diff --git a/webtoolbar.py b/webtoolbar.py
> index 9e0f660..1a0e112 100644
> --- a/webtoolbar.py
> +++ b/webtoolbar.py
> @@ -26,6 +26,7 @@ from xpcom import components
>
> from sugar.graphics.toolbutton import ToolButton
> from sugar.graphics.menuitem import MenuItem
> +from sugar.graphics.iconentry import IconEntry
> try:
> from sugar.graphics.toolbarbox import ToolbarBox as ToolbarBase
> from sugar.activity.widgets import ActivityToolbarButton
> @@ -43,7 +44,7 @@ import places
> _MAX_HISTORY_ENTRIES = 15
>
>
> -class WebEntry(gtk.Entry):
> +class WebEntry(IconEntry):
> _COL_ADDRESS = 0
> _COL_TITLE = 1
>
> @@ -260,12 +261,10 @@ class PrimaryToolbar(ToolbarBase):
> toolbar.insert(self._go_home, -1)
> self._go_home.show()
>
> - self._stop_and_reload = ToolButton('media-playback-stop')
> - self._stop_and_reload.connect('clicked', self._stop_and_reload_cb)
> - toolbar.insert(self._stop_and_reload, -1)
> - self._stop_and_reload.show()
> -
> self.entry = WebEntry()
> + self.entry.set_icon_from_name(gtk.ENTRY_ICON_SECONDARY,
> + 'browse-dialog-cancel')
> + self.entry.connect('icon-press', self._stop_and_reload_cb)
> self.entry.connect('activate', self._entry_activate_cb)
>
> entry_item = gtk.ToolItem()
> @@ -400,10 +399,12 @@ class PrimaryToolbar(ToolbarBase):
> self.entry.props.title = title
>
> def _show_stop_icon(self):
> - self._stop_and_reload.set_icon('media-playback-stop')
> + self.entry.set_icon_from_name(gtk.ENTRY_ICON_SECONDARY,
> + 'browse-dialog-cancel')
>
> def _show_reload_icon(self):
> - self._stop_and_reload.set_icon('view-refresh')
> + self.entry.set_icon_from_name(gtk.ENTRY_ICON_SECONDARY,
> + 'browse-view-refresh')
>
> def _update_navigation_buttons(self):
> browser = self._tabbed_view.props.current_browser
> @@ -436,7 +437,7 @@ class PrimaryToolbar(ToolbarBase):
> def _title_changed_cb(self, embed, spec):
> self._set_title(embed.props.title)
>
> - def _stop_and_reload_cb(self, button):
> + def _stop_and_reload_cb(self, entry, icon_pos, button):
> browser = self._tabbed_view.props.current_browser
> if self._loading:
> browser.web_navigation.stop(interfaces.nsIWebNavigation.STOP_ALL)
> @@ -449,10 +450,8 @@ class PrimaryToolbar(ToolbarBase):
>
> if self._loading:
> self._show_stop_icon()
> - self._stop_and_reload.set_tooltip(_('Stop'))
> else:
> self._show_reload_icon()
> - self._stop_and_reload.set_tooltip(_('Reload'))
>
> def _reload_session_history(self, current_page_index=None):
> browser = self._tabbed_view.props.current_browser
> --
> 1.7.4.4
>
> _______________________________________________
> Sugar-devel mailing list
> Sugar-devel at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel
>
Tested in the XO. The url entry now takes 1/3 of the screen width,
and the graphics look clear.
Tested-By: Manuel Quiñones <manuq at laptop.org>
Reviewed-By: Manuel Quiñones <manuq at laptop.org>
--
.. manuq ..
More information about the Sugar-devel
mailing list