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