[Sugar-devel] [PATCH Browse] Display only the URL in the URL entry SL #3553
Martin Langhoff
martin.langhoff at gmail.com
Thu Sep 27 10:25:24 EDT 2012
Is this really an improvement in behaviour?
- The tabs are often too small to show the title.
- The title is more important for the user than the URL. No?
cheers,
m
On Mon, Sep 24, 2012 at 5:09 PM, Manuel Kaufmann <humitos at gmail.com> wrote:
> The Title of the current page is no longer shown in the URL
> entry. Now, it's only shown in the tab and the current URL is visible
> all the time in the URL entry.
>
> Signed-off-by: Manuel Kaufmann <humitos at gmail.com>
> ---
> browser.py | 13 +++++++++++++
> webtoolbar.py | 53 +++++------------------------------------------------
> 2 files changed, 18 insertions(+), 48 deletions(-)
>
> diff --git a/browser.py b/browser.py
> index de546f2..1c67beb 100644
> --- a/browser.py
> +++ b/browser.py
> @@ -453,6 +453,10 @@ class Browser(WebKit.WebView):
> # Scale text and graphics:
> self.set_full_content_zoom(True)
>
> + # This property is used to set the title immediatly the user
> + # presses Enter on the URL Entry
> + self._loading_uri = None
> +
> # Reference to the global history and callbacks to handle it:
> self._global_history = globalhistory.get_global_history()
> self.connect('notify::load-status', self.__load_status_changed_cb)
> @@ -542,6 +546,15 @@ class Browser(WebKit.WebView):
> def open_new_tab(self, url):
> self.emit('new-tab', url)
>
> + def _set_loading_uri(self, uri):
> + self._loading_uri = uri
> +
> + def _get_loading_uri(self):
> + return self._loading_uri
> +
> + loading_uri = GObject.property(type=str, setter=_set_loading_uri,
> + getter=_get_loading_uri)
> +
> def __run_file_chooser(self, browser, request):
> picker = FilePicker(self)
> chosen = picker.run()
> diff --git a/webtoolbar.py b/webtoolbar.py
> index 28bc015..1d531bc 100644
> --- a/webtoolbar.py
> +++ b/webtoolbar.py
> @@ -47,7 +47,6 @@ class WebEntry(iconentry.IconEntry):
> GObject.GObject.__init__(self)
>
> self._address = None
> - self._title = None
> self._search_view = self._search_create_view()
>
> self._search_window = Gtk.Window(type=Gtk.WindowType.POPUP)
> @@ -57,8 +56,6 @@ class WebEntry(iconentry.IconEntry):
> self.connect('focus-in-event', self.__focus_in_event_cb)
> self.connect('populate-popup', self.__populate_popup_cb)
> self.connect('key-press-event', self.__key_press_event_cb)
> - self.connect('enter-notify-event', self.__enter_notify_event_cb)
> - self.connect('leave-notify-event', self.__leave_notify_event_cb)
> self._focus_out_hid = self.connect(
> 'focus-out-event', self.__focus_out_event_cb)
> self._change_hid = self.connect('changed', self.__changed_cb)
> @@ -79,18 +76,11 @@ class WebEntry(iconentry.IconEntry):
>
> def _set_address(self, address):
> self._address = address
> - if address is not None and self.props.has_focus:
> + if address is not None:
> self._set_text(address)
>
> address = GObject.property(type=str, setter=_set_address)
>
> - def _set_title(self, title):
> - self._title = title
> - if title is not None and not self.props.has_focus:
> - self._set_text(title)
> -
> - title = GObject.property(type=str, setter=_set_title)
> -
> def _search_create_view(self):
> view = Gtk.TreeView()
> view.props.headers_visible = False
> @@ -146,21 +136,11 @@ class WebEntry(iconentry.IconEntry):
> self._search_window.hide()
>
> def __focus_in_event_cb(self, entry, event):
> - self._set_text(self._address)
> self._search_popdown()
>
> def __focus_out_event_cb(self, entry, event):
> - self._set_text(self._title)
> self._search_popdown()
>
> - def __enter_notify_event_cb(self, entry, event):
> - if not entry.props.has_focus:
> - self._set_text(self._address)
> -
> - def __leave_notify_event_cb(self, entry, event):
> - if not entry.props.has_focus:
> - self._set_text(self._title)
> -
> def __view_button_press_event_cb(self, view, event):
> model = view.get_model()
>
> @@ -241,7 +221,6 @@ class PrimaryToolbar(ToolbarBase):
> self._tabbed_view = tabbed_view
>
> self._loading = False
> - self._title = _('Untitled')
>
> toolbar = self.toolbar
> activity_button = ActivityToolbarButton(self._activity)
> @@ -310,7 +289,6 @@ class PrimaryToolbar(ToolbarBase):
> self._loading_changed_hid = None
> self._progress_changed_hid = None
> self._session_history_changed_hid = None
> - self._title_changed_hid = None
> self._uri_changed_hid = None
>
> if tabbed_view.get_n_pages():
> @@ -324,25 +302,19 @@ class PrimaryToolbar(ToolbarBase):
>
> def _connect_to_browser(self, browser):
> if self._browser is not None:
> - self._browser.disconnect(self._title_changed_hid)
> self._browser.disconnect(self._uri_changed_hid)
> self._browser.disconnect(self._progress_changed_hid)
> self._browser.disconnect(self._loading_changed_hid)
>
> self._browser = browser
> - if self._browser.props.title:
> - self._set_title(self._browser.props.title)
> - else:
> - self._set_title(_('Untitled'))
> - self._set_address(self._browser.props.uri)
> + address = self._browser.props.uri or self._browser.props.loading_uri
> + self._set_address(address)
> self._set_progress(self._browser.props.progress)
> self._set_status(self._browser.props.load_status)
>
> is_webkit_browser = isinstance(self._browser, Browser)
> self.entry.props.editable = is_webkit_browser
>
> - self._title_changed_hid = self._browser.connect(
> - 'notify::title', self._title_changed_cb)
> self._uri_changed_hid = self._browser.connect(
> 'notify::uri', self.__uri_changed_cb)
> self._progress_changed_hid = self._browser.connect(
> @@ -353,16 +325,6 @@ class PrimaryToolbar(ToolbarBase):
> self._update_navigation_buttons()
>
> def __loading_changed_cb(self, widget, param):
> - status = widget.get_load_status()
> - if status == WebKit.LoadStatus.FAILED:
> - self.entry._set_title(self._title)
> - elif WebKit.LoadStatus.PROVISIONAL <= status \
> - < WebKit.LoadStatus.FINISHED:
> - self.entry._set_title(_('Loading...'))
> - elif status == WebKit.LoadStatus.FINISHED:
> - if widget.props.title == None:
> - self.entry._set_title(_('Untitled'))
> - self._title = _('Untitled')
> self._set_status(widget.get_load_status())
>
> def __progress_changed_cb(self, widget, param):
> @@ -383,10 +345,6 @@ class PrimaryToolbar(ToolbarBase):
> else:
> self.entry.props.address = uri
>
> - def _set_title(self, title):
> - self.entry.props.title = title
> - self._title = title
> -
> def _show_stop_icon(self):
> self.entry.set_icon_from_name(iconentry.ICON_ENTRY_SECONDARY,
> 'browse-dialog-cancel')
> @@ -412,6 +370,8 @@ class PrimaryToolbar(ToolbarBase):
> url = entry.props.text
> effective_url = self._tabbed_view.normalize_or_autosearch_url(url)
> self._browser.load_uri(effective_url)
> + self._browser.props.loading_uri = effective_url
> + self.entry.props.address = effective_url
> self._browser.grab_focus()
>
> def _go_home_cb(self, button):
> @@ -423,9 +383,6 @@ class PrimaryToolbar(ToolbarBase):
> def _go_forward_cb(self, button):
> self._browser.go_forward()
>
> - def _title_changed_cb(self, widget, param):
> - self._set_title(widget.get_title())
> -
> def __uri_changed_cb(self, widget, param):
> self._set_address(widget.get_uri())
> self._update_navigation_buttons()
> --
> 1.7.11.4
>
> _______________________________________________
> Sugar-devel mailing list
> Sugar-devel at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel
--
martin.langhoff at gmail.com
martin at laptop.org -- Software Architect - OLPC
- ask interesting questions
- don't get distracted with shiny stuff - working code first
- http://wiki.laptop.org/go/User:Martinlanghoff
More information about the Sugar-devel
mailing list