Commit 0fb8dc6d authored by Cédric Bellegarde's avatar Cédric Bellegarde

Do not access SitesManager from PagesManager

parent 5c58652f
...@@ -94,15 +94,6 @@ class PagesManager(Gtk.EventBox): ...@@ -94,15 +94,6 @@ class PagesManager(Gtk.EventBox):
else: else:
style_context.remove_class(class_name) style_context.remove_class(class_name)
def destroy(self):
"""
Destroy widget and child
"""
# We force child to disconnect from view
for child in self.__box.get_children():
child.destroy()
Gtk.EventBox.destroy(self)
def search_grab_focus(self): def search_grab_focus(self):
""" """
Grab focus on search entry Grab focus on search entry
...@@ -172,7 +163,7 @@ class PagesManager(Gtk.EventBox): ...@@ -172,7 +163,7 @@ class PagesManager(Gtk.EventBox):
GLib.Variant("(i)", (page_id,)), GLib.Variant("(i)", (page_id,)),
self.__on_forms_filled, page_id, view) self.__on_forms_filled, page_id, view)
def close_view(self, view, animate=True): def close_view(self, view):
""" """
close current view close current view
@param view as View @param view as View
...@@ -198,11 +189,6 @@ class PagesManager(Gtk.EventBox): ...@@ -198,11 +189,6 @@ class PagesManager(Gtk.EventBox):
view.webview.ephemeral, view.webview.ephemeral,
view.webview.get_session_state()) view.webview.get_session_state())
child.destroy() child.destroy()
# Delay view destroy to allow stack animation
if animate:
GLib.timeout_add(1000, view.destroy)
else:
view.destroy()
# Nothing to do if was not current page # Nothing to do if was not current page
if not was_current: if not was_current:
return False return False
......
...@@ -77,7 +77,7 @@ class PagesManagerChild(Gtk.FlowBoxChild): ...@@ -77,7 +77,7 @@ class PagesManagerChild(Gtk.FlowBoxChild):
self.__connected_ids.append( self.__connected_ids.append(
self.__view.webview.connect( self.__view.webview.connect(
"favicon-changed", "favicon-changed",
self.__on_webview_notify_favicon)) self.__on_webview_favicon_changed))
self.__connected_ids.append( self.__connected_ids.append(
self.__view.webview.connect( self.__view.webview.connect(
"notify::is-playing-audio", "notify::is-playing-audio",
...@@ -218,28 +218,27 @@ class PagesManagerChild(Gtk.FlowBoxChild): ...@@ -218,28 +218,27 @@ class PagesManagerChild(Gtk.FlowBoxChild):
def __on_destroy(self, widget): def __on_destroy(self, widget):
""" """
Disconnect signals Disconnect signals and destroy view
@param widget as Gtk.Widget @param widget as Gtk.Widget
""" """
self.__window.container.sites_manager.remove_view(self.__view)
while self.__connected_ids: while self.__connected_ids:
connected_id = self.__connected_ids.pop(0) connected_id = self.__connected_ids.pop(0)
self.__view.webview.disconnect(connected_id) self.__view.webview.disconnect(connected_id)
if self.__view_destroy_id is not None: if self.__view_destroy_id is not None:
self.__view.disconnect(self.__view_destroy_id) self.__view.disconnect(self.__view_destroy_id)
self.__view.destroy()
def __on_view_destroy(self, view): def __on_view_destroy(self, view):
""" """
Destroy self Destroy self as view has been destroyed
@param view as View @param view as View
""" """
self.__connected_ids = [] self.__connected_ids = []
self.__view_destroy_id = None self.__view_destroy_id = None
self.__window.container.sites_manager.remove_view(self.__view) self.destroy()
GLib.idle_add(self.destroy)
def __on_webview_notify_favicon(self, webview, favicon, def __on_webview_favicon_changed(self, webview, favicon,
icon_theme_artwork): icon_theme_artwork):
""" """
Set favicon Set favicon
@param webview as WebView @param webview as WebView
...@@ -249,10 +248,6 @@ class PagesManagerChild(Gtk.FlowBoxChild): ...@@ -249,10 +248,6 @@ class PagesManagerChild(Gtk.FlowBoxChild):
self.__favicon = favicon self.__favicon = favicon
if favicon is not None: if favicon is not None:
self.__close_button.get_image().set_from_surface(favicon) self.__close_button.get_image().set_from_surface(favicon)
# Update site manager favicon (missing or obsolete)
self.__window.container.sites_manager.set_favicon(
self.__view,
favicon)
else: else:
self.__close_button.get_image().set_from_icon_name( self.__close_button.get_image().set_from_icon_name(
icon_theme_artwork, icon_theme_artwork,
...@@ -304,8 +299,6 @@ class PagesManagerChild(Gtk.FlowBoxChild): ...@@ -304,8 +299,6 @@ class PagesManagerChild(Gtk.FlowBoxChild):
@param title as str @param title as str
""" """
self.__indicator_label.set_text(title) self.__indicator_label.set_text(title)
self.__window.container.sites_manager.update_label(
self.__window.container.current)
def __on_webview_load_changed(self, webview, event): def __on_webview_load_changed(self, webview, event):
""" """
......
...@@ -84,6 +84,8 @@ class SitesManagerChild(Gtk.ListBoxRow): ...@@ -84,6 +84,8 @@ class SitesManagerChild(Gtk.ListBoxRow):
if view not in self.__views: if view not in self.__views:
self.__views.append(view) self.__views.append(view)
view.webview.connect("shown", self.__on_webview_shown) view.webview.connect("shown", self.__on_webview_shown)
view.webview.connect("favicon-changed",
self.__on_webview_favicon_changed)
self.__indicator_label.shown(view.webview.shown) self.__indicator_label.shown(view.webview.shown)
self.__update_indicator(view) self.__update_indicator(view)
self.update_label() self.update_label()
...@@ -142,13 +144,6 @@ class SitesManagerChild(Gtk.ListBoxRow): ...@@ -142,13 +144,6 @@ class SitesManagerChild(Gtk.ListBoxRow):
else: else:
self.__netloc_label.set_text(self.__netloc) self.__netloc_label.set_text(self.__netloc)
def set_favicon(self, surface):
"""
Set favicon
@param surface as cairo.Surface
"""
self.__image.set_from_surface(surface)
@property @property
def empty(self): def empty(self):
""" """
...@@ -268,6 +263,17 @@ class SitesManagerChild(Gtk.ListBoxRow): ...@@ -268,6 +263,17 @@ class SitesManagerChild(Gtk.ListBoxRow):
resized = get_char_surface(parsed.netloc.lstrip("www.")[0]) resized = get_char_surface(parsed.netloc.lstrip("www.")[0])
self.__image.set_from_surface(resized) self.__image.set_from_surface(resized)
def __on_webview_favicon_changed(self, webview, favicon,
icon_theme_artwork):
"""
Set favicon
@param webview as WebView
@param favicon as cairo.Surface
@param icon_theme_artwork as str
"""
if favicon is not None:
self.__image.set_from_surface(favicon)
def __on_query_tooltip(self, widget, x, y, keyboard, tooltip): def __on_query_tooltip(self, widget, x, y, keyboard, tooltip):
""" """
Show tooltip if needed Show tooltip if needed
......
...@@ -42,7 +42,7 @@ class View(Gtk.Overlay): ...@@ -42,7 +42,7 @@ class View(Gtk.Overlay):
""" """
Gtk.Overlay.__init__(self) Gtk.Overlay.__init__(self)
self.__reading_view = None self.__reading_view = None
self._window = window self.__window = window
self.__webview = webview self.__webview = webview
webview.set_view(self) webview.set_view(self)
self.__webview.show() self.__webview.show()
...@@ -115,12 +115,10 @@ class View(Gtk.Overlay): ...@@ -115,12 +115,10 @@ class View(Gtk.Overlay):
def destroy(self): def destroy(self):
""" """
Destroy view and webview Delayed destroy
""" """
Gtk.Overlay.destroy(self) self.__window.container.sites_manager.remove_view(self)
self.__webview.destroy() GLib.timeout_add(1000, self.__destroy)
if self.__reading_view is not None:
self.__reading_view.destroy()
@property @property
def reading(self): def reading(self):
...@@ -149,6 +147,15 @@ class View(Gtk.Overlay): ...@@ -149,6 +147,15 @@ class View(Gtk.Overlay):
####################### #######################
# PRIVATE # # PRIVATE #
####################### #######################
def __destroy(self):
"""
Destroy view and webview
"""
Gtk.Overlay.destroy(self)
self.__webview.destroy()
if self.__reading_view is not None:
self.__reading_view.destroy()
def __on_key_press_event(self, widget, event): def __on_key_press_event(self, widget, event):
""" """
Handle Ctrl+Z and Ctrl+Shift+Z (forms undo/redo) Handle Ctrl+Z and Ctrl+Shift+Z (forms undo/redo)
...@@ -168,7 +175,7 @@ class View(Gtk.Overlay): ...@@ -168,7 +175,7 @@ class View(Gtk.Overlay):
@param webview as WebView @param webview as WebView
""" """
if self.get_ancestor(Gtk.Popover) is None: if self.get_ancestor(Gtk.Popover) is None:
self._window.container.pages_manager.try_close_view(self) self.__window.container.pages_manager.try_close_view(self)
def __on_mouse_target_changed(self, webview, hit, modifiers): def __on_mouse_target_changed(self, webview, hit, modifiers):
""" """
...@@ -189,4 +196,4 @@ class View(Gtk.Overlay): ...@@ -189,4 +196,4 @@ class View(Gtk.Overlay):
@param webview as WebView @param webview as WebView
""" """
if webview.get_mapped(): if webview.get_mapped():
self._window.toolbar.title.show_readable_button(True) self.__window.toolbar.title.show_readable_button(True)
...@@ -201,6 +201,7 @@ class WebViewLoadSignals: ...@@ -201,6 +201,7 @@ class WebViewLoadSignals:
""" """
if webview.get_mapped(): if webview.get_mapped():
self._window.toolbar.title.set_title(title) self._window.toolbar.title.set_title(title)
self._window.container.sites_manager.update_label(self.view)
def __on_estimated_load_progress(self, webview, value): def __on_estimated_load_progress(self, webview, value):
""" """
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment