Commit 25922663 authored by Cédric Bellegarde's avatar Cédric Bellegarde

If a child is destroyed and none is visible, mark first visible. If a view is...

If a child is destroyed and none is visible, mark first visible. If a view is selected, destroy child
parent 4148366e
......@@ -158,6 +158,8 @@ class Container(Gtk.Overlay):
view.set_size_request(-1, -1)
self.__stack.add(view)
self.__stack.set_visible_child(view)
if self.__pages_overlay is not None:
self.__pages_overlay.destroy_child(view)
def stop(self):
"""
......
......@@ -335,7 +335,6 @@ class PagesManager(Gtk.EventBox):
if next_row is not None:
self._window.container.set_visible_view(next_row.view)
self.update_visible_child()
GLib.timeout_add(1000, view.destroy)
def __scroll_to_child(self, row):
"""
......
......@@ -384,9 +384,10 @@ class PagesManagerChild:
if self.__view_destroy_id is not None:
self._view.disconnect(self.__view_destroy_id)
def __on_view_destroy(self, widget):
def __on_view_destroy(self, view):
"""
Destroy self
@param view as View
"""
self.__connected_ids = []
self.__view_destroy_id = None
......
......@@ -73,9 +73,7 @@ class PagesManagerFlowBoxCustom(PagesManagerFlowBox):
@param listbox as Gtk.ListBox
@param row as PagesManagerFlowBoxChild
"""
self._window.container.set_visible_view(row.view)
self._window.container.set_expose(False)
self._window.container.pages_manager.update_visible_child()
PagesManagerFlowBox._on_child_activated(self, listbox, row)
GLib.idle_add(row.destroy)
def __on_scroll_event(self, scrolled, event):
......@@ -162,6 +160,15 @@ class PagesOverlay(Gtk.EventBox):
self.__pages_manager.show()
self.__pages_manager.hide_next()
def destroy_child(self, view):
"""
Destroy child related to view
@param view as View
"""
for child in self.__pages_manager.children:
if child.view == view:
child.destroy()
break
#######################
# PROTECTED #
#######################
......@@ -170,12 +177,16 @@ class PagesOverlay(Gtk.EventBox):
#######################
# PRIVATE #
#######################
def __on_child_destroy(self, widget):
def __on_child_destroy(self, child):
"""
Hide self if empty
@param widget as Gtk.Widget
@param child as PagesManagerFlowBoxChild
"""
if not self.__pages_manager.children:
if self.__pages_manager.children:
first = self.__pages_manager.children[0]
if not first.is_visible():
first.show()
else:
self.hide()
self.__fake.hide()
self.__pages_manager.hide()
......
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