[Sugar-devel] [PATCH 2/2] Restore url-entry showing url, title and progress bar
Manuel Quiñones
manuq at laptop.org
Tue Nov 29 11:29:21 EST 2011
Signed-off-by: Manuel Quiñones <manuq at laptop.org>
---
webtoolbar.py | 69 ++++++++++++++++++++++++++------------------------------
1 files changed, 32 insertions(+), 37 deletions(-)
diff --git a/webtoolbar.py b/webtoolbar.py
index af89fb5..c9b85f2 100644
--- a/webtoolbar.py
+++ b/webtoolbar.py
@@ -288,11 +288,11 @@ class PrimaryToolbar(ToolbarBase):
self._history = None
self._browser = None
- self._location_changed_hid = None
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
GObject.idle_add(lambda:
self._connect_to_browser(tabbed_view.props.current_browser))
@@ -303,43 +303,36 @@ class PrimaryToolbar(ToolbarBase):
self._connect_to_browser(tabbed_view.props.current_browser)
def _connect_to_browser(self, browser):
- if self._progress_listener is not None:
- self._progress_listener.disconnect(self._location_changed_hid)
- self._progress_listener.disconnect(self._loading_changed_hid)
- self._progress_listener.disconnect(self._progress_changed_hid)
-
- self._progress_listener = browser.progress
- self._set_progress(self._progress_listener.progress)
- if self._progress_listener.location:
- self._set_address(self._progress_listener.location)
- else:
- self._set_address(None)
- self._set_loading(self._progress_listener.loading)
- self._update_navigation_buttons()
- self._location_changed_hid = self._progress_listener.connect(
- 'notify::location', self.__location_changed_cb)
- self._loading_changed_hid = self._progress_listener.connect(
- 'notify::loading', self.__loading_changed_cb)
- self._progress_changed_hid = self._progress_listener.connect(
- 'notify::progress', self.__progress_changed_cb)
+ # FIXME
+ # self._set_loading(self._progress_listener.loading)
+ # self._update_navigation_buttons()
- if self._history is not None:
- self._history.disconnect(self._session_history_changed_hid)
+ # if self._history is not None:
+ # self._history.disconnect(self._session_history_changed_hid)
- self._history = browser.history
- self._session_history_changed_hid = self._history.connect(
- 'session-history-changed', self._session_history_changed_cb)
- self._reload_session_history()
+ # self._history = browser.history
+ # self._session_history_changed_hid = self._history.connect(
+ # 'session-history-changed', self._session_history_changed_cb)
+ # self._reload_session_history()
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 = browser
self._set_title(self._browser.props.title)
+ self._set_address(self._browser.props.uri)
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(
+ 'notify::progress', self.__progress_changed_cb)
+ self._loading_changed_hid = self._browser.connect(
+ 'notify::load-status', self.__loading_changed_cb)
def _session_history_changed_cb(self, session_history, current_page_index):
# We have to wait until the history info is updated.
@@ -351,13 +344,14 @@ class PrimaryToolbar(ToolbarBase):
filepicker.cleanup_temp_files()
def __loading_changed_cb(self, progress_listener, pspec):
- if progress_listener.loading:
+ status = widget.get_load_status()
+ if status <= WebKit.LoadStatus.COMMITTED:
self._set_title(None)
- self._set_loading(progress_listener.loading)
+ self._set_loading(status >= WebKit.LoadStatus.FINISHED)
self._update_navigation_buttons()
- def __progress_changed_cb(self, progress_listener, pspec):
- self._set_progress(progress_listener.progress)
+ def __progress_changed_cb(self, widget, param):
+ self._set_progress(widget.get_progress())
def _set_progress(self, progress):
if progress == 1.0:
@@ -366,11 +360,7 @@ class PrimaryToolbar(ToolbarBase):
self.entry.set_progress_fraction(progress)
def _set_address(self, uri):
- if uri and self._browser is not None:
- ui_uri = self._browser.get_url_from_nsiuri(uri)
- else:
- ui_uri = None
- self.entry.props.address = ui_uri
+ self.entry.props.address = uri
def _set_title(self, title):
self.entry.props.title = title
@@ -408,8 +398,13 @@ class PrimaryToolbar(ToolbarBase):
browser = self._tabbed_view.props.current_browser
browser.web_navigation.goForward()
- def _title_changed_cb(self, embed, spec):
- self._set_title(embed.props.title)
+ 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()
+ filepicker.cleanup_temp_files()
def _stop_and_reload_cb(self, entry, icon_pos, button):
browser = self._tabbed_view.props.current_browser
--
1.7.7.3
More information about the Sugar-devel
mailing list