def build_widget(self): self.titlebar = self.make_titlebar() self.widget.titlebar_vbox.pack_start(self.titlebar) self.status_toolbar = DownloadStatusToolbar() self.widget.statusbar_vbox.pack_start(self.status_toolbar) self._update_free_space()
def build_widget(self): self.titlebar.switch_to_view(self.widget.selected_view) self.widget.titlebar_vbox.pack_start(self.titlebar) self.status_toolbar = DownloadStatusToolbar() self.widget.statusbar_vbox.pack_start(self.status_toolbar) self._update_free_space()
def build_widget(self): self._make_item_views() self.titlebar = self.make_titlebar() self.widget.titlebar_vbox.pack_start(self.titlebar) self.toolbar = DownloadToolbar() self.toolbar.connect("pause-all", self._on_pause_all) self.toolbar.connect("resume-all", self._on_resume_all) self.toolbar.connect("cancel-all", self._on_cancel_all) self.toolbar.connect("settings", self._on_settings) self.widget.titlebar_vbox.pack_start(self.toolbar) vbox = widgetset.VBox() vbox.pack_start(self.indydownloads_section) vbox.pack_start(self.downloads_section) vbox.pack_start(self.seeding_section) background = widgetset.SolidBackground((1, 1, 1)) background.add(vbox) scroller = widgetset.Scroller(False, True) scroller.add(background) self.widget.normal_view_vbox.pack_start(scroller, expand=True) self.status_toolbar = DownloadStatusToolbar() self.widget.statusbar_vbox.pack_start(self.status_toolbar) self._update_free_space()
class DownloadsController(itemlistcontroller.ItemListController): def __init__(self): itemlistcontroller.ItemListController.__init__( self, u'downloading', u'downloading') self.item_list.resort_on_update = True self.toolbar = None def build_widget(self): self.titlebar = self.make_titlebar() self.widget.titlebar_vbox.pack_start(self.titlebar) self.status_toolbar = DownloadStatusToolbar() self.widget.statusbar_vbox.pack_start(self.status_toolbar) self._update_free_space() def on_config_change(self, obj, key, value): itemlistcontroller.ItemListController.on_config_change(self, obj, key, value) if ((key == prefs.PRESERVE_X_GB_FREE.key or key == prefs.PRESERVE_DISK_SPACE.key)): self.status_toolbar.update_free_space() def make_titlebar(self): titlebar = DownloadTitlebar() titlebar.connect('search-changed', self._on_search_changed) titlebar.connect("pause-all", self._on_pause_all) titlebar.connect("resume-all", self._on_resume_all) titlebar.connect("cancel-all", self._on_cancel_all) titlebar.connect("settings", self._on_settings) titlebar.switch_to_view(self.widget.selected_view) return titlebar def make_context_menu_handler(self): return itemcontextmenu.ItemContextMenuHandler() def _on_search_changed(self, widget, search_text): self.set_search(search_text) def _update_free_space(self): self.status_toolbar.update_free_space() def _on_pause_all(self, widget): messages.PauseAllDownloads().send_to_backend() def _on_resume_all(self, widget): messages.ResumeAllDownloads().send_to_backend() def _on_cancel_all(self, widget): messages.CancelAllDownloads().send_to_backend() def _on_settings(self, widget): prefpanel.show_window("downloads") def on_items_changed(self): self.status_toolbar.update_rates( downloader.total_down_rate, downloader.total_up_rate)
class DownloadsController(itemlistcontroller.ItemListController): def __init__(self): itemlistcontroller.ItemListController.__init__( self, u'downloading', u'downloading') self.toolbar = None self.update_buttons() def build_widget(self): self.titlebar.switch_to_view(self.widget.selected_view) self.widget.titlebar_vbox.pack_start(self.titlebar) self.status_toolbar = DownloadStatusToolbar() self.widget.statusbar_vbox.pack_start(self.status_toolbar) self._update_free_space() def on_config_change(self, obj, key, value): itemlistcontroller.ItemListController.on_config_change(self, obj, key, value) if ((key == prefs.PRESERVE_X_GB_FREE.key or key == prefs.PRESERVE_DISK_SPACE.key)): self.status_toolbar.update_free_space() def make_titlebar(self): titlebar = DownloadTitlebar() titlebar.connect('search-changed', self._on_search_changed) titlebar.connect("pause-all", self._on_pause_all) titlebar.connect("resume-all", self._on_resume_all) titlebar.connect("cancel-all", self._on_cancel_all) titlebar.connect("settings", self._on_settings) titlebar.hide_album_view_button() return titlebar def make_context_menu_handler(self): return itemcontextmenu.ItemContextMenuHandler() def _on_search_changed(self, widget, search_text): self.set_search(search_text) def _update_free_space(self): self.status_toolbar.update_free_space() # The pause_all/resume_all and cancel_all disables the automatic sorting # mechanism until the operations are complete, because even though the # operation affects all items in the list the status updates for these # items are not batched. # # When complete, the backend is expected to send a reply indicating that # all operations (up to this point) are complete and at that point we can # re-enable the sort again. See DownloadSyncCommandComplete(). We hope # for the best that the remote command to do whatever's needed should not # take more than a second or two which should be accurate for a moderately # sized download list. def _on_pause_all(self, widget): messages.PauseAllDownloads().send_to_backend() def _on_resume_all(self, widget): messages.ResumeAllDownloads().send_to_backend() def _on_cancel_all(self, widget): messages.CancelAllDownloads().send_to_backend() def _on_settings(self, widget): prefpanel.show_window("downloads") def handle_item_list_changes(self): itemlistcontroller.ItemListController.handle_item_list_changes(self) self.update_rates() self.update_buttons() def update_rates(self): self.status_toolbar.update_rates( app.download_state_manager.total_down_rate, app.download_state_manager.total_up_rate) def update_buttons(self): items = self.item_list.get_items() if len(items) == 0: self.titlebar.set_button_enabled("resume", False) self.titlebar.set_button_enabled("pause", False) self.titlebar.set_button_enabled("cancel", False) else: all_paused = all_downloading = True for item in items: if item.is_paused: all_downloading = False else: all_paused = False self.titlebar.set_button_enabled("resume", not all_downloading) self.titlebar.set_button_enabled("pause", not all_paused) self.titlebar.set_button_enabled("cancel", True)
class DownloadsController(itemlistcontroller.ItemListController): def __init__(self): itemlistcontroller.ItemListController.__init__( self, u'downloading', u'downloading') self.toolbar = None self.update_buttons() def build_widget(self): self.titlebar = self.make_titlebar() self.widget.titlebar_vbox.pack_start(self.titlebar) self.status_toolbar = DownloadStatusToolbar() self.widget.statusbar_vbox.pack_start(self.status_toolbar) self._update_free_space() def on_config_change(self, obj, key, value): itemlistcontroller.ItemListController.on_config_change(self, obj, key, value) if ((key == prefs.PRESERVE_X_GB_FREE.key or key == prefs.PRESERVE_DISK_SPACE.key)): self.status_toolbar.update_free_space() def make_titlebar(self): titlebar = DownloadTitlebar() titlebar.connect('search-changed', self._on_search_changed) titlebar.connect("pause-all", self._on_pause_all) titlebar.connect("resume-all", self._on_resume_all) titlebar.connect("cancel-all", self._on_cancel_all) titlebar.connect("settings", self._on_settings) titlebar.switch_to_view(self.widget.selected_view) titlebar.hide_album_view_button() return titlebar def make_context_menu_handler(self): return itemcontextmenu.ItemContextMenuHandler() def _on_search_changed(self, widget, search_text): self.set_search(search_text) def _update_free_space(self): self.status_toolbar.update_free_space() # The pause_all/resume_all and cancel_all disables the automatic sorting # mechanism until the operations are complete, because even though the # operation affects all items in the list the status updates for these # items are not batched. # # When complete, the backend is expected to send a reply indicating that # all operations (up to this point) are complete and at that point we can # re-enable the sort again. See DownloadSyncCommandComplete(). We hope # for the best that the remote command to do whatever's needed should not # take more than a second or two which should be accurate for a moderately # sized download list. def _on_pause_all(self, widget): messages.PauseAllDownloads().send_to_backend() def _on_resume_all(self, widget): messages.ResumeAllDownloads().send_to_backend() def _on_cancel_all(self, widget): messages.CancelAllDownloads().send_to_backend() def _on_settings(self, widget): prefpanel.show_window("downloads") def handle_item_list_changes(self): itemlistcontroller.ItemListController.handle_item_list_changes(self) self.update_rates() self.update_buttons() def update_rates(self): self.status_toolbar.update_rates( app.download_state_manager.total_down_rate, app.download_state_manager.total_up_rate) def update_buttons(self): items = self.item_list.get_items() if len(items) == 0: self.titlebar.set_button_enabled("resume", False) self.titlebar.set_button_enabled("pause", False) self.titlebar.set_button_enabled("cancel", False) else: all_paused = all_downloading = True for item in items: if item.is_paused: all_downloading = False else: all_paused = False self.titlebar.set_button_enabled("resume", not all_downloading) self.titlebar.set_button_enabled("pause", not all_paused) self.titlebar.set_button_enabled("cancel", True)
class DownloadsController(itemlistcontroller.ItemListController): def __init__(self): itemlistcontroller.ItemListController.__init__(self, 'downloading', None) for item_list in self.item_list_group.item_lists: item_list.resort_on_update = True def build_widget(self): self._make_item_views() self.titlebar = self.make_titlebar() self.widget.titlebar_vbox.pack_start(self.titlebar) self.toolbar = DownloadToolbar() self.toolbar.connect("pause-all", self._on_pause_all) self.toolbar.connect("resume-all", self._on_resume_all) self.toolbar.connect("cancel-all", self._on_cancel_all) self.toolbar.connect("settings", self._on_settings) self.widget.titlebar_vbox.pack_start(self.toolbar) vbox = widgetset.VBox() vbox.pack_start(self.indydownloads_section) vbox.pack_start(self.downloads_section) vbox.pack_start(self.seeding_section) background = widgetset.SolidBackground((1, 1, 1)) background.add(vbox) scroller = widgetset.Scroller(False, True) scroller.add(background) self.widget.normal_view_vbox.pack_start(scroller, expand=True) self.status_toolbar = DownloadStatusToolbar() self.widget.statusbar_vbox.pack_start(self.status_toolbar) self._update_free_space() def make_titlebar(self): image_path = resources.path("images/icon-downloading_large.png") icon = imagepool.get(image_path) titlebar = ItemListTitlebar(_("Downloads"), icon) titlebar.connect('search-changed', self._on_search_changed) return titlebar def make_context_menu_handler(self): return itemcontextmenu.ItemContextMenuHandler() def _make_item_views(self): self.indydownloads_view = ItemView( itemlist.IndividualDownloadItemList()) self.indydownloads_section = HideableSection( _("Single and external downloads"), self.indydownloads_view) self.downloads_view = ItemView(itemlist.ChannelDownloadItemList()) self.downloads_section = HideableSection( _("Feed downloads"), self.downloads_view) self.seeding_view = ItemView(itemlist.SeedingItemList()) self.seeding_section = HideableSection(_("Seeding"), self.seeding_view) def normal_item_views(self): return [self.indydownloads_view, self.downloads_view, self.seeding_view] def default_item_view(self): return self.downloads_view def _on_search_changed(self, widget, search_text): self.set_search(search_text) def _update_free_space(self): self.status_toolbar.update_free_space() def _on_pause_all(self, widget): messages.PauseAllDownloads().send_to_backend() def _on_resume_all(self, widget): messages.ResumeAllDownloads().send_to_backend() def _on_cancel_all(self, widget): messages.CancelAllDownloads().send_to_backend() def _on_settings(self, widget): prefpanel.show_window("downloads") def _expand_lists_initially(self): self.indydownloads_section.show() self.downloads_section.show() if len(self.indydownloads_view.item_list.get_items()) > 0: self.indydownloads_section.show() else: self.indydownloads_section.hide() if len(self.downloads_view.item_list.get_items()) > 0: self.downloads_section.show() else: self.downloads_section.hide() if len(self.seeding_view.item_list.get_items()) > 0: self.seeding_section.show() else: self.seeding_section.hide() self.indydownloads_section.expand() self.downloads_section.expand() self.seeding_section.expand() def on_initial_list(self): self._expand_lists_initially() def on_items_changed(self): self.status_toolbar.update_rates( downloader.total_down_rate, downloader.total_up_rate) if len(self.indydownloads_view.item_list.get_items()) > 0: self.indydownloads_section.show() else: self.indydownloads_section.hide() if len(self.downloads_view.item_list.get_items()) > 0: self.downloads_section.show() else: self.downloads_section.hide() if len(self.seeding_view.item_list.get_items()) > 0: self.seeding_section.show() else: self.seeding_section.hide()