Commit 0130f090 authored by Cédric Bellegarde's avatar Cédric Bellegarde

Fix web page closing

parent dd5195f0
......@@ -224,7 +224,9 @@ class Container(Gtk.Overlay):
@param animate as bool
"""
# Get children less view
children = self.__stack.get_children()
children = self.__get_children()
if view.destroying:
return
children.remove(view)
reversed_children = list(reversed(children))
children_count = len(children)
......@@ -322,6 +324,14 @@ class Container(Gtk.Overlay):
view.show()
return view
def __get_children(self):
"""
Get children
@return [View]
"""
return [child for child in self.__stack.get_children()
if not child.destroying]
def __on_paned_notify_position(self, paned, ignore):
"""
Update SitesManager width based on current position
......
......@@ -80,7 +80,7 @@ class SitesMenu(Gio.Menu):
"""
for view in self.__window.container.views:
if view in views:
self.__window.container.pages_manager.try_close_view(view)
self.__window.container.try_close_view(view)
def __on_modify_ua_activate(self, action, param, views):
"""
......
......@@ -73,20 +73,29 @@ class PagesManagerChild(Gtk.FlowBoxChild):
ArtSize.PREVIEW_WIDTH_MARGIN)
self.connect("query-tooltip", self.__on_query_tooltip)
view.connect("destroying", self.__on_view_destroying)
self.__view.webview.connect("favicon-changed",
self.__on_webview_favicon_changed)
self.__view.webview.connect("notify::is-playing-audio",
self.__on_webview_notify_is_playing_audio)
self.__view.webview.connect("uri-changed",
self.__on_webview_uri_changed)
self.__view.webview.connect("title-changed",
self.__on_webview_title_changed)
self.__view.webview.connect("scroll-event",
self.__on_webview_scroll_event)
self.__view.webview.connect("load-changed",
self.__on_webview_load_changed)
self.__view.webview.connect("shown",
self.__on_webview_shown)
self.__connected_signals = []
self.__connected_signals.append(
self.__view.webview.connect("favicon-changed",
self.__on_webview_favicon_changed))
self.__connected_signals.append(
self.__view.webview.connect(
"notify::is-playing-audio",
self.__on_webview_notify_is_playing_audio))
self.__connected_signals.append(
self.__view.webview.connect("uri-changed",
self.__on_webview_uri_changed))
self.__connected_signals.append(
self.__view.webview.connect("title-changed",
self.__on_webview_title_changed))
self.__connected_signals.append(
self.__view.webview.connect("scroll-event",
self.__on_webview_scroll_event))
self.__connected_signals.append(
self.__view.webview.connect("load-changed",
self.__on_webview_load_changed))
self.__connected_signals.append(
self.__view.webview.connect("shown",
self.__on_webview_shown))
@property
def view(self):
......@@ -106,7 +115,7 @@ class PagesManagerChild(Gtk.FlowBoxChild):
@param event as Gdk.Event
"""
if event.button == 2:
self.__window.container.pages_manager.try_close_view(self.__view)
self.__window.container.try_close_view(self.__view)
return True
def _on_button_release_event(self, eventbox, event):
......@@ -121,7 +130,7 @@ class PagesManagerChild(Gtk.FlowBoxChild):
Destroy self
@param button as Gtk.Button
"""
self.__window.container.pages_manager.try_close_view(self.__view)
self.__window.container.try_close_view(self.__view)
return True
def _on_enter_notify_event(self, eventbox, event):
......@@ -217,6 +226,8 @@ class PagesManagerChild(Gtk.FlowBoxChild):
Destroy self
@param view as View
"""
for signal_id in self.__connected_signals:
self.__view.webview.disconnect(signal_id)
self.destroy()
def __on_webview_favicon_changed(self, webview, favicon,
......
......@@ -180,7 +180,7 @@ class SitesManagerChild(Gtk.ListBoxRow):
@param button as Gtk.Button
"""
for view in self.__views:
self.__window.container.pages_manager.try_close_view(view)
self.__window.container.try_close_view(view)
def _on_scroll_event(self, eventbox, event):
"""
......@@ -203,7 +203,7 @@ class SitesManagerChild(Gtk.ListBoxRow):
"""
if event.button == 2:
for view in self.__views:
self.__window.container.pages_manager.try_close_view(view)
self.__window.container.try_close_view(view)
return True
elif event.button == 3:
from eolie.menu_sites import SitesMenu
......
......@@ -47,6 +47,7 @@ class View(Gtk.Overlay):
"""
Gtk.Overlay.__init__(self)
self.__reading_view = None
self.__destroying = False
self.__window = window
self.__webview = webview
self.__subsurface = subsurface
......@@ -123,9 +124,18 @@ class View(Gtk.Overlay):
"""
Delayed destroy
"""
self.__destroying = True
self.emit("destroying")
GLib.timeout_add(1000, self.__destroy)
@property
def destroying(self):
"""
Destroy is pending
@return bool
"""
return self.__destroying
@property
def subsurface(self):
"""
......@@ -189,7 +199,7 @@ class View(Gtk.Overlay):
@param webview as WebView
"""
if self.get_ancestor(Gtk.Popover) is None:
self.__window.container.pages_manager.try_close_view(self)
self.__window.container.close_view(self)
def __on_mouse_target_changed(self, webview, hit, modifiers):
"""
......
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