From 54a38310d336dc6ffc764b6d6a5efe8ed3a54159 Mon Sep 17 00:00:00 2001
From: Manuel Kaufmann <humitos@gmail.com>
Date: Mon, 24 Sep 2012 17:40:34 -0300
Subject: [PATCH Browse] Display only the URL in the URL entry SL #3553
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@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
|
b
|
class Browser(WebKit.WebView): |
453 | 453 | # Scale text and graphics: |
454 | 454 | self.set_full_content_zoom(True) |
455 | 455 | |
| 456 | # This property is used to set the title immediatly the user |
| 457 | # presses Enter on the URL Entry |
| 458 | self._loading_uri = None |
| 459 | |
456 | 460 | # Reference to the global history and callbacks to handle it: |
457 | 461 | self._global_history = globalhistory.get_global_history() |
458 | 462 | self.connect('notify::load-status', self.__load_status_changed_cb) |
… |
… |
class Browser(WebKit.WebView): |
542 | 546 | def open_new_tab(self, url): |
543 | 547 | self.emit('new-tab', url) |
544 | 548 | |
| 549 | def _set_loading_uri(self, uri): |
| 550 | self._loading_uri = uri |
| 551 | |
| 552 | def _get_loading_uri(self): |
| 553 | return self._loading_uri |
| 554 | |
| 555 | loading_uri = GObject.property(type=str, setter=_set_loading_uri, |
| 556 | getter=_get_loading_uri) |
| 557 | |
545 | 558 | def __run_file_chooser(self, browser, request): |
546 | 559 | picker = FilePicker(self) |
547 | 560 | chosen = picker.run() |
diff --git a/webtoolbar.py b/webtoolbar.py
index 28bc015..1d531bc 100644
a
|
b
|
class WebEntry(iconentry.IconEntry): |
47 | 47 | GObject.GObject.__init__(self) |
48 | 48 | |
49 | 49 | self._address = None |
50 | | self._title = None |
51 | 50 | self._search_view = self._search_create_view() |
52 | 51 | |
53 | 52 | self._search_window = Gtk.Window(type=Gtk.WindowType.POPUP) |
… |
… |
class WebEntry(iconentry.IconEntry): |
57 | 56 | self.connect('focus-in-event', self.__focus_in_event_cb) |
58 | 57 | self.connect('populate-popup', self.__populate_popup_cb) |
59 | 58 | self.connect('key-press-event', self.__key_press_event_cb) |
60 | | self.connect('enter-notify-event', self.__enter_notify_event_cb) |
61 | | self.connect('leave-notify-event', self.__leave_notify_event_cb) |
62 | 59 | self._focus_out_hid = self.connect( |
63 | 60 | 'focus-out-event', self.__focus_out_event_cb) |
64 | 61 | self._change_hid = self.connect('changed', self.__changed_cb) |
… |
… |
class WebEntry(iconentry.IconEntry): |
79 | 76 | |
80 | 77 | def _set_address(self, address): |
81 | 78 | self._address = address |
82 | | if address is not None and self.props.has_focus: |
| 79 | if address is not None: |
83 | 80 | self._set_text(address) |
84 | 81 | |
85 | 82 | address = GObject.property(type=str, setter=_set_address) |
86 | 83 | |
87 | | def _set_title(self, title): |
88 | | self._title = title |
89 | | if title is not None and not self.props.has_focus: |
90 | | self._set_text(title) |
91 | | |
92 | | title = GObject.property(type=str, setter=_set_title) |
93 | | |
94 | 84 | def _search_create_view(self): |
95 | 85 | view = Gtk.TreeView() |
96 | 86 | view.props.headers_visible = False |
… |
… |
class WebEntry(iconentry.IconEntry): |
146 | 136 | self._search_window.hide() |
147 | 137 | |
148 | 138 | def __focus_in_event_cb(self, entry, event): |
149 | | self._set_text(self._address) |
150 | 139 | self._search_popdown() |
151 | 140 | |
152 | 141 | def __focus_out_event_cb(self, entry, event): |
153 | | self._set_text(self._title) |
154 | 142 | self._search_popdown() |
155 | 143 | |
156 | | def __enter_notify_event_cb(self, entry, event): |
157 | | if not entry.props.has_focus: |
158 | | self._set_text(self._address) |
159 | | |
160 | | def __leave_notify_event_cb(self, entry, event): |
161 | | if not entry.props.has_focus: |
162 | | self._set_text(self._title) |
163 | | |
164 | 144 | def __view_button_press_event_cb(self, view, event): |
165 | 145 | model = view.get_model() |
166 | 146 | |
… |
… |
class PrimaryToolbar(ToolbarBase): |
241 | 221 | self._tabbed_view = tabbed_view |
242 | 222 | |
243 | 223 | self._loading = False |
244 | | self._title = _('Untitled') |
245 | 224 | |
246 | 225 | toolbar = self.toolbar |
247 | 226 | activity_button = ActivityToolbarButton(self._activity) |
… |
… |
class PrimaryToolbar(ToolbarBase): |
310 | 289 | self._loading_changed_hid = None |
311 | 290 | self._progress_changed_hid = None |
312 | 291 | self._session_history_changed_hid = None |
313 | | self._title_changed_hid = None |
314 | 292 | self._uri_changed_hid = None |
315 | 293 | |
316 | 294 | if tabbed_view.get_n_pages(): |
… |
… |
class PrimaryToolbar(ToolbarBase): |
324 | 302 | |
325 | 303 | def _connect_to_browser(self, browser): |
326 | 304 | if self._browser is not None: |
327 | | self._browser.disconnect(self._title_changed_hid) |
328 | 305 | self._browser.disconnect(self._uri_changed_hid) |
329 | 306 | self._browser.disconnect(self._progress_changed_hid) |
330 | 307 | self._browser.disconnect(self._loading_changed_hid) |
331 | 308 | |
332 | 309 | self._browser = browser |
333 | | if self._browser.props.title: |
334 | | self._set_title(self._browser.props.title) |
335 | | else: |
336 | | self._set_title(_('Untitled')) |
337 | | self._set_address(self._browser.props.uri) |
| 310 | address = self._browser.props.uri or self._browser.props.loading_uri |
| 311 | self._set_address(address) |
338 | 312 | self._set_progress(self._browser.props.progress) |
339 | 313 | self._set_status(self._browser.props.load_status) |
340 | 314 | |
341 | 315 | is_webkit_browser = isinstance(self._browser, Browser) |
342 | 316 | self.entry.props.editable = is_webkit_browser |
343 | 317 | |
344 | | self._title_changed_hid = self._browser.connect( |
345 | | 'notify::title', self._title_changed_cb) |
346 | 318 | self._uri_changed_hid = self._browser.connect( |
347 | 319 | 'notify::uri', self.__uri_changed_cb) |
348 | 320 | self._progress_changed_hid = self._browser.connect( |
… |
… |
class PrimaryToolbar(ToolbarBase): |
353 | 325 | self._update_navigation_buttons() |
354 | 326 | |
355 | 327 | def __loading_changed_cb(self, widget, param): |
356 | | status = widget.get_load_status() |
357 | | if status == WebKit.LoadStatus.FAILED: |
358 | | self.entry._set_title(self._title) |
359 | | elif WebKit.LoadStatus.PROVISIONAL <= status \ |
360 | | < WebKit.LoadStatus.FINISHED: |
361 | | self.entry._set_title(_('Loading...')) |
362 | | elif status == WebKit.LoadStatus.FINISHED: |
363 | | if widget.props.title == None: |
364 | | self.entry._set_title(_('Untitled')) |
365 | | self._title = _('Untitled') |
366 | 328 | self._set_status(widget.get_load_status()) |
367 | 329 | |
368 | 330 | def __progress_changed_cb(self, widget, param): |
… |
… |
class PrimaryToolbar(ToolbarBase): |
383 | 345 | else: |
384 | 346 | self.entry.props.address = uri |
385 | 347 | |
386 | | def _set_title(self, title): |
387 | | self.entry.props.title = title |
388 | | self._title = title |
389 | | |
390 | 348 | def _show_stop_icon(self): |
391 | 349 | self.entry.set_icon_from_name(iconentry.ICON_ENTRY_SECONDARY, |
392 | 350 | 'browse-dialog-cancel') |
… |
… |
class PrimaryToolbar(ToolbarBase): |
412 | 370 | url = entry.props.text |
413 | 371 | effective_url = self._tabbed_view.normalize_or_autosearch_url(url) |
414 | 372 | self._browser.load_uri(effective_url) |
| 373 | self._browser.props.loading_uri = effective_url |
| 374 | self.entry.props.address = effective_url |
415 | 375 | self._browser.grab_focus() |
416 | 376 | |
417 | 377 | def _go_home_cb(self, button): |
… |
… |
class PrimaryToolbar(ToolbarBase): |
423 | 383 | def _go_forward_cb(self, button): |
424 | 384 | self._browser.go_forward() |
425 | 385 | |
426 | | def _title_changed_cb(self, widget, param): |
427 | | self._set_title(widget.get_title()) |
428 | | |
429 | 386 | def __uri_changed_cb(self, widget, param): |
430 | 387 | self._set_address(widget.get_uri()) |
431 | 388 | self._update_navigation_buttons() |