Commit 86932d7b authored by Cédric Bellegarde's avatar Cédric Bellegarde

Hide the download button when no download. Fix #312

parent f7a66a06
......@@ -106,7 +106,7 @@
</child>
<child>
<object class="GtkToggleButton" id="download_button">
<property name="visible">True</property>
<property name="visible">False</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Downloads</property>
......@@ -135,7 +135,7 @@
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">3</property>
<property name="position">4</property>
</packing>
</child>
<child>
......@@ -151,7 +151,7 @@
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">4</property>
<property name="position">3</property>
</packing>
</child>
</object>
......
......@@ -135,7 +135,7 @@ class ToolbarMenu(Gtk.PopoverMenu):
Show download popover
@param button as Gtk.Button
"""
self.__toolbar._on_download_button_toggled(button)
self.__toolbar._on_download_button_toggled(self.__toolbar.menu_button)
def _on_zoom_button_clicked(self, button):
"""
......
......@@ -332,12 +332,8 @@ class DownloadsPopover(Gtk.Popover):
Clear finished downloads
@param button as Gtk.button
"""
self.__clear_button.set_sensitive(False)
for child in self.__listbox.get_children():
if isinstance(child, DownloadRow):
if child.finished:
App().download_manager.remove(child.download)
child.destroy()
self.popdown()
self.__window.toolbar.end.download_button.hide()
#######################
# PRIVATE #
......
......@@ -167,14 +167,20 @@ class ToolbarEnd(Gtk.Bin):
@param b as bool
"""
if b:
self.__download_button.hide()
self.__home_button.hide()
self.set_hexpand(False)
else:
self.__download_button.show()
self.__home_button.show()
self.set_hexpand(True)
@property
def menu_button(self):
"""
Get download button
@return Gtk.ToogleButton
"""
return self.__menu_button
@property
def download_button(self):
"""
......@@ -192,11 +198,11 @@ class ToolbarEnd(Gtk.Bin):
@param button as Gtk.Button
"""
self.__window.close_popovers()
if not button.get_active():
if button == self.__download_button and not button.get_active():
return
popover = DownloadsPopover(self.__window)
# We are relative to toolbar button, button can be in menu
popover.set_relative_to(self.__download_button)
popover.set_relative_to(button)
popover.connect("closed", self.__on_popover_closed, button)
popover.set_modal(False)
self.__window.register(popover)
......@@ -369,6 +375,10 @@ class ToolbarEnd(Gtk.Bin):
@param name as str (do not use this)
"""
if download_manager.active:
# Show button if needed
if not self.__download_button.is_visible() and\
self.__home_button.is_visible():
self.__download_button.show()
if self.__timeout_id is None:
self.__progress.show()
self.__timeout_id = GLib.timeout_add(1000,
......
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